List of usage examples for javax.servlet.http HttpServletRequest getRequestURI
public String getRequestURI();
From source file:com.qq.common.WrappedController.java
@ExceptionHandler(Exception.class) @ResponseBody/*from w w w . java 2 s. c o m*/ public Object handleException(HttpServletRequest request, Exception e) { boolean isAjax = isAjaxRequest(request); log.info("exception intercepted, uri={}, isajax={}", request.getRequestURI(), isAjax, e); ExceptionResponse response; if (e instanceof CodeEnabled) { CodeEnabled ce = (CodeEnabled) e; response = new ExceptionResponse(EC_INTERNAL_DEFAULT, ce.getFullCode(), ce.getMessageForUser()); } else { response = new ExceptionResponse(EC_INTERNAL_DEFAULT, StringUtils.EMPTY, e.getMessage()); } response.setAttached(new ExceptionResponseAttached().loadFromRequest(request)); if (isAjax) { return response; } else { ModelAndView mv = new ModelAndView(); mv.setViewName("exception"); mv.addObject("response", response); return mv; } }
From source file:edu.pitt.dbmi.ccd.anno.error.ErrorMessage.java
/** * Constructor/*ww w . j a v a2s. c om*/ * * @param http http status * @param message error message * @param req http servlet request * @return ErrorMessage with current timestamp, status and error from * HttpStatus, message, and path from HttpServletRequest */ public ErrorMessage(HttpStatus http, String message, HttpServletRequest req) { this.timestamp = new Date(); this.status = http.value(); this.error = http.getReasonPhrase(); this.message = message; this.path = req.getRequestURI(); }
From source file:com.qq.common.WrappedController.java
@ExceptionHandler(value = { MethodArgumentNotValidException.class, MissingServletRequestParameterException.class, ServletRequestBindingException.class, UnsatisfiedServletRequestParameterException.class, ServletRequestParameterException.class }) @ResponseBody//from ww w .j a v a 2 s . c om public Object handleRequestFormatException(HttpServletRequest request, Exception e) { boolean isAjax = isAjaxRequest(request); log.info("exception intercepted, uri={}, isajax={}", request.getRequestURI(), isAjax, e); String msg = e.getMessage(); if (e instanceof MethodArgumentNotValidException) { msg = BindingResultMessage.get(((MethodArgumentNotValidException) e).getBindingResult()); } ExceptionResponse response = new ExceptionResponse(EC_SUCCESS, EC_PARAMETER_WRONG, msg); response.setAttached(new ExceptionResponseAttached().loadFromRequest(request)); if (isAjax) { return response; } else { ModelAndView mv = new ModelAndView(); mv.setViewName("exception"); mv.addObject("response", response); return mv; } }
From source file:fr.aliasource.webmail.proxy.Controller.java
/** * Verifies login & creates imap caching proxy if valid. * /*from w ww . j av a 2 s .co m*/ * @param req * @param responder */ private void validateLoginRequest(HttpServletRequest req, IResponder responder) { if ("/login.do".equals(req.getRequestURI())) { loginHandling(req, responder, false); } else if ("/firstIndexing.do".equals(req.getRequestURI())) { IProxy p = loginHandling(req, responder, true); if (p != null) { try { Thread.sleep(20 * 1000); } catch (InterruptedException e) { } logout(p); responder.sendString("First indexing complete."); } else { logger.error("null proxy from loginHandling", new Throwable()); } logger.info("leaving first indexing"); } else { responder.denyAccess("not a login request"); } }
From source file:edu.chalmers.dat076.moviefinder.filter.UserFilter.java
@Override protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws ServletException, IOException { HttpSession session = req.getSession(true); String path = req.getRequestURI().substring(req.getContextPath().length()); Object o = session.getAttribute("user"); if (o == null) { if (path.toLowerCase().startsWith("/api/login/login")) { chain.doFilter(req, res);/*from w w w.j av a 2 s . c o m*/ return; } else if (path.toLowerCase().startsWith("/api/")) { res.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return; } else { chain.doFilter(req, res); return; } } User u = (User) o; if (path.toLowerCase().startsWith("/api/admin") && u.getRole() != UserRole.ADMIN) { res.setStatus(HttpServletResponse.SC_FORBIDDEN); return; } chain.doFilter(req, res); }
From source file:com.lti.system.MyLogoutFilter.java
/** * Allow subclasses to modify when a logout should take place. * * @param request the request// w w w .j a va 2 s . c o m * @param response the response * * @return <code>true</code> if logout should occur, <code>false</code> otherwise */ protected boolean requiresLogout(HttpServletRequest request, HttpServletResponse response) { String uri = request.getRequestURI(); int pathParamIndex = uri.indexOf(';'); if (pathParamIndex > 0) { // strip everything from the first semi-colon uri = uri.substring(0, pathParamIndex); } int queryParamIndex = uri.indexOf('?'); if (queryParamIndex > 0) { // strip everything from the first question mark uri = uri.substring(0, queryParamIndex); } if ("".equals(request.getContextPath())) { return uri.endsWith(filterProcessesUrl); } return uri.endsWith(request.getContextPath() + filterProcessesUrl); }
From source file:org.tsm.concharto.web.filter.NotificationFilter.java
public void doFilter(ServletRequest servletRequest, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; //Ignore URLs like embedded maps String ignore = filterConfig.getInitParameter(CONFIG_IGNORE); if (!StringUtils.contains(request.getRequestURI(), ignore)) { String username = AuthHelper.getUsername(); if (notificationDao.notificationsExist(username)) { WebUtils.setSessionAttribute(request, SESSION_MESSAGES_PENDING, "yes"); }/*w w w. ja v a 2 s . c om*/ } chain.doFilter(request, response); }
From source file:com.tbodt.jswerve.servlet.JSwerveServlet.java
private URI extractUri(HttpServletRequest req) throws ServletException { try {//from w w w . ja v a2s . c o m return new URI(req.getScheme(), UrlUtils.decode(req.getServerName()), UrlUtils.decode(req.getRequestURI()), UrlUtils.decode(req.getQueryString()), null); } catch (URISyntaxException ex) { throw new ServletException("Damn! URI syntax!", ex); } }
From source file:com.kdgregory.pathfinder.test.spring3.pkg2.ControllerE.java
@RequestMapping(value = "/E2") protected ModelAndView getBar(HttpServletRequest request, HttpServletResponse response, @RequestParam String argle, @RequestParam Integer bargle) throws Exception { ModelAndView mav = new ModelAndView("simple"); mav.addObject("reqUrl", request.getRequestURI()); mav.addObject("controller", getClass().getName()); mav.addObject("argle", argle); mav.addObject("bargle", bargle); return mav;//from w w w . j av a2 s . co m }
From source file:org.toobsframework.pres.doit.controller.strategy.DefaultForwardStrategy.java
protected String getErrorUri(HttpServletRequest httpRequest) { String requestUri = httpRequest.getRequestURI(); if (requestUri != null) { requestUri = this.stripHost(requestUri); }/*from w w w . j a va 2s . c o m*/ return requestUri; }