List of usage examples for javax.servlet.http HttpServletRequest getRequestURI
public String getRequestURI();
From source file:com.qcadoo.report.internal.controller.ReportController.java
private ReportService.ReportType getReportType(final HttpServletRequest request) throws ReportException { String uri = request.getRequestURI(); String type = uri.substring(uri.lastIndexOf('.') + 1).toUpperCase(Locale.getDefault()); try {/* ww w .j a v a 2 s .c om*/ return ReportService.ReportType.valueOf(type); } catch (IllegalArgumentException e) { throw new ReportException(ReportException.Type.WRONG_REPORT_TYPE, e, type); } }
From source file:gallery.web.controller.misc.PathController.java
@RequestMapping @ResponseBody/* w ww .j av a 2 s . c o m*/ public String hello(HttpServletRequest request) { logger.info("encoding=" + request.getCharacterEncoding()); logger.info("info=" + request.getPathInfo()); logger.info("uri=" + request.getRequestURI()); logger.info("hello"); return "hello world<br>" + "info=" + request.getPathInfo() + "<br>uri=" + request.getRequestURI(); }
From source file:com.lc.storefront.interceptors.beforeview.CartRestorationBeforeViewHandler.java
/** * Decide whether or not the modifications related to the cart restoration or merge should be displayed in the * notifications/*from ww w . j a va 2 s.c o m*/ * * @param request * @return whether or not to display the modifications */ protected Boolean showModifications(final HttpServletRequest request) { for (final String targetPage : getPagesToShowModifications()) { if (StringUtils.contains(request.getRequestURI().toString(), targetPage)) { return Boolean.TRUE; } } return Boolean.FALSE; }
From source file:com.bstek.dorado.idesupport.resolver.RobotResolver.java
protected String getRobotName(HttpServletRequest request) { String uri = request.getRequestURI(); int i = uri.lastIndexOf("/"); if (i > 0 && i < uri.length() - 1) { return uri.substring(i + 1); }//from ww w. ja v a2 s . c o m return null; }
From source file:net.acesinc.convergentui.BaseFilter.java
protected boolean isConvergentUIRequest(HttpServletRequest request) { String path = request.getRequestURI(); return path.startsWith("/cui-req://"); }
From source file:com.temenos.interaction.core.web.RequestContextFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final HttpServletRequest servletRequest = (HttpServletRequest) request; String requestURI = servletRequest.getRequestURI(); requestURI = StringUtils.removeStart(requestURI, servletRequest.getContextPath() + servletRequest.getServletPath()); String baseURL = StringUtils.removeEnd(servletRequest.getRequestURL().toString(), requestURI); Map<String, List<String>> headersMap = new HashMap<>(); Enumeration<String> headerNames = servletRequest.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); List<String> valuesList = Collections.list(servletRequest.getHeaders(headerName)); headersMap.put(headerName, valuesList); }// w ww . ja v a 2 s . c om } RequestContext ctx; Principal userPrincipal = servletRequest.getUserPrincipal(); if (userPrincipal != null) { ctx = new RequestContext(baseURL, servletRequest.getRequestURI(), servletRequest.getHeader(RequestContext.HATEOAS_OPTIONS_HEADER), userPrincipal, headersMap); } else { ctx = new RequestContext(baseURL, servletRequest.getRequestURI(), servletRequest.getHeader(RequestContext.HATEOAS_OPTIONS_HEADER), headersMap); } RequestContext.setRequestContext(ctx); try { chain.doFilter(request, response); } finally { RequestContext.clearRequestContext(); } }
From source file:edu.cornell.mannlib.vitro.webapp.filters.PageRoutingFilter.java
@Override public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain chain) throws IOException, ServletException { ServletContext ctx = filterConfig.getServletContext(); PageDao pageDao = ModelAccess.on(ctx).getWebappDaoFactory().getPageDao(); Map<String, String> urlMappings = pageDao.getPageMappings(); // get URL without hostname or servlet context HttpServletResponse response = (HttpServletResponse) arg1; HttpServletRequest req = (HttpServletRequest) arg0; String path = req.getRequestURI().substring(req.getContextPath().length()); // check for first part of path // ex. /hats/superHat -> /hats Matcher m = urlPartPattern.matcher(path); if (m.matches() && m.groupCount() >= 1) { String path1stPart = m.group(1); String pageUri = urlMappings.get(path1stPart); //try it with a leading slash? if (pageUri == null) pageUri = urlMappings.get("/" + path1stPart); if (pageUri != null && !pageUri.isEmpty()) { log.debug(path + "is a request to a page defined in the display model as " + pageUri); //add the pageUri to the request scope for use by the PageController PageController.putPageUri(req, pageUri); //This will send requests to HomePageController or PageController String controllerName = getControllerToForwardTo(req, pageUri, pageDao); log.debug(path + " is being forwarded to controller " + controllerName); RequestDispatcher rd = ctx.getNamedDispatcher(controllerName); if (rd == null) { log.error(path + " should be forwarded to controller " + controllerName + " but there " + "is no servlet named that defined for the web application in web.xml"); //TODO: what should be done in this case? }/*from ww w . ja va2s.c om*/ rd.forward(req, response); } else if ("/".equals(path) || path.isEmpty()) { log.debug("url '" + path + "' is being forward to home controller"); RequestDispatcher rd = ctx.getNamedDispatcher(HOME_CONTROLLER_NAME); rd.forward(req, response); } else { doNonDisplayPage(path, arg0, arg1, chain); } } else { doNonDisplayPage(path, arg0, arg1, chain); } }
From source file:cn.sel.wetty.interceptor.AccessLogger.java
private void i(HttpServletRequest request) { String msg = String.format("%s -> %s\t[%s]\tHeaders:%s\tParameters:%s", request.getRemoteAddr(), request.getRequestURI(), request.getMethod(), getHeaders(request), request.getParameterMap()); LOGGER.info(msg);//from w ww . j a v a 2 s . co m }
From source file:com.kdgregory.pathfinder.test.spring3.pkg2.ControllerD.java
@RequestMapping(value = "{id}", method = RequestMethod.GET) protected ModelAndView getD(HttpServletRequest request, HttpServletResponse response, @PathVariable String id) throws Exception { ModelAndView mav = new ModelAndView("simple"); mav.addObject("reqUrl", request.getRequestURI()); mav.addObject("controller", getClass().getName()); mav.addObject("id", id); return mav;//from w w w .ja va2 s .com }
From source file:io.apiman.manager.test.server.MockGatewayServlet.java
/** * @see javax.servlet.http.HttpServlet#doPut(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from w w w . j a va 2 s . c o m @Override protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { builder.append("PUT:").append(req.getRequestURI()).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ payloads.add(getPayload(req)); resp.setStatus(204); }