List of usage examples for javax.servlet.http HttpServletRequest getRequestURL
public StringBuffer getRequestURL();
From source file:QueryModifier.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { String requestUrl = request.getRequestURL().toString(); String querystr = request.getQueryString(); if (querystr != null) { querystr = querystr + "&inspector-name=Jen&inspector-email=Jenniferq@yahoo.com"; } else {//w ww . ja v a 2s. c om querystr = "inspector-name=Jen&inspector-email=Jenniferq@yahoo.com"; } RequestDispatcher dispatcher = request.getRequestDispatcher("/viewPost.jsp?" + querystr); dispatcher.forward(request, response); }
From source file:demo.oauth.client.controllers.CallbackURLController.java
@RequestMapping("/callback") protected ModelAndView handleRequest(@ModelAttribute("oAuthParams") OAuthParams oAuthParams, HttpServletRequest request) throws Exception { OAuthMessage message = OAuthServlet.getMessage(request, request.getRequestURL().toString()); try {//www . j ava2 s . co m message.requireParameters(OAuth.OAUTH_TOKEN, OAuth.OAUTH_VERIFIER); oAuthParams.setOauthToken(message.getToken()); oAuthParams.setOauthVerifier(message.getParameter(OAuth.OAUTH_VERIFIER)); oAuthParams.setClientID(Common.findCookieValue(request, "clientID")); oAuthParams.setClientSecret(Common.findCookieValue(request, "clientSecret")); } catch (OAuthProblemException e) { oAuthParams.setErrorMessage("OAuth problem: " + e.getProblem() + e.getParameters().toString()); } return new ModelAndView("tokenRequest"); }
From source file:ua.epam.rd.web.GlobalErrorHandler.java
@ExceptionHandler(NotFoundPizzaException.class) public ModelAndView exceptionHandler(Exception exception, HttpServletRequest req) { ModelAndView model = new ModelAndView("error"); model.addObject("ex", exception); model.addObject("url", req.getRequestURL()); return model; }
From source file:br.com.mv.modulo.web.ExceptionController.java
@ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(GenericException.class) @ResponseBody/*w ww . jav a2s . c o m*/ ExceptionInfo handleBadRequest(HttpServletRequest req, GenericException ex) { return new ExceptionInfo(req.getRequestURL(), ex); }
From source file:com.janrain.servlet.ProcessTimeLoggingFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest servletRequest = (HttpServletRequest) request; if (servletRequest.getRequestURL().indexOf("http://localhost") != 0) { long start = System.currentTimeMillis(); chain.doFilter(request, response); long stop = System.currentTimeMillis(); StringBuilder output = new StringBuilder(); output.append("Time [ ").append(stop - start).append(" ms ]"); output.append(" Request [").append(servletRequest.getRequestURL()); if (servletRequest.getQueryString() != null) { output.append("?").append(servletRequest.getQueryString()); }/*from w ww. j a v a 2 s .co m*/ output.append("]"); output.append(" Remote Addr [ ").append(servletRequest.getRemoteAddr()).append(" ] "); String referer = servletRequest.getHeader("referer"); if (StringUtils.isNotBlank(referer)) { output.append(" Referer [ ").append(referer).append(" ] "); } String userAgent = servletRequest.getHeader("user-agent"); if (StringUtils.isNotBlank(userAgent)) { output.append(" [ ").append(userAgent).append(" ] "); } logger.debug(output); } else { chain.doFilter(request, response); } }
From source file:com.miserablemind.butter.apps.butterApp.controller.ControllerExceptionHandler.java
/** * Handles "Not Found" scenario and renders a 404 page. * * @param request http request used for getting the URL and wiring config into model * @param exception exception that was thrown, in this case {@link com.miserablemind.butter.apps.butterApp.exception.HTTPNotFoundException} * @return logical name of a view to render *///ww w . j a v a2s. co m @ResponseStatus(HttpStatus.NOT_FOUND) // 404 @ExceptionHandler(HTTPNotFoundException.class) public String handleNotFound(HttpServletRequest request, Exception exception) { logger.error("[404] Request: " + request.getRequestURL() + " raised " + exception, exception); request.setAttribute("configApp", this.config); if (Utilities.getAuthUserId() == 0) return "guest/errors/404"; return "errors/404"; }
From source file:com.miserablemind.butter.apps.butterApp.controller.ControllerExceptionHandler.java
/** * Handles "Bad Request" scenario and renders a 400 page. * * @param request http request used for getting the URL and wiring config into model * @param exception exception that was thrown, in this case {@link com.miserablemind.butter.apps.butterApp.exception.HTTPBadRequestException} * @return logical name of a view to render *//* w w w .j a v a 2s . co m*/ @ResponseStatus(HttpStatus.BAD_REQUEST) // 400 @ExceptionHandler(HTTPBadRequestException.class) public String handleBadRequest(HttpServletRequest request, Exception exception) { logger.error("[400] Request: " + request.getRequestURL() + " raised " + exception, exception); request.setAttribute("configApp", this.config); if (Utilities.getAuthUserId() == 0) return "guest/errors/400"; return "errors/400"; }
From source file:com.miserablemind.butter.apps.butterApp.controller.ControllerExceptionHandler.java
/** * Handles "Internal Server Error" scenario and renders a 500 page. * * @param request http request used for getting the URL and wiring config into model * @param exception exception that was thrown, in this case {@link com.miserablemind.butter.apps.butterApp.exception.HTTPBadRequestException} or {@link DataAccessException} * @return logical name of a view to render */// w w w.j a v a 2s.co m @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) // 500 @ExceptionHandler({ DataAccessException.class, HTTPInternalServerErrorException.class }) public String handleInternalServerError(HttpServletRequest request, Exception exception) { logger.error("[500] Request: " + request.getRequestURL() + " raised " + exception, exception); request.setAttribute("configApp", this.config); if (Utilities.getAuthUserId() == 0) return "guest/errors/500"; return "errors/500"; }
From source file:org.openwms.tms.api.TransportationController.java
private String getCreatedResourceURI(HttpServletRequest req, String objId) { StringBuffer url = req.getRequestURL(); UriTemplate template = new UriTemplate(url.append("/{objId}/").toString()); return template.expand(objId).toASCIIString(); }
From source file:net.paulgray.mocklti2.web.Lti2ConsumerController.java
@RequestMapping(value = "/") public String getWelcome(HttpServletRequest request, ModelMap model) { model.addAttribute("contextPath", request.getContextPath()); model.addAttribute("contextUrl", request.getRequestURL()); model.addAttribute("contextUri", request.getRequestURI()); return "welcome"; }