List of usage examples for javax.servlet.http HttpServletRequest getRequestURI
public String getRequestURI();
From source file:org.archive.wayback.webapp.RequestMapper.java
private String getContextID(HttpServletRequest request) { String requestPath = request.getRequestURI(); String contextPath = request.getContextPath(); if (requestPath.startsWith(contextPath)) { requestPath = requestPath.substring(contextPath.length()); }// ww w . j a v a2s. c om String collection = ""; if (requestPath.startsWith("/")) { int secondSlash = requestPath.indexOf("/", 1); if (secondSlash != -1) { collection = PORT_SEPARATOR + requestPath.substring(1, requestPath.indexOf("/", 1)); } else { collection = PORT_SEPARATOR + requestPath.substring(1); } } return String.valueOf(request.getLocalPort()) + collection; }
From source file:com.surevine.alfresco.audit.listeners.UpdateDocumentMetadataAuditEventListener.java
@Override public boolean isEventFired(final HttpServletRequest request) { for (String desig : URI_DESIGNATORS) { if (request.getRequestURI().contains(desig)) { return true; }//from w w w.j a v a 2s. c om } return false; }
From source file:cn.guoyukun.spring.web.interceptor.SetCommonDataInterceptor.java
private String extractCurrentURL(HttpServletRequest request, boolean needQueryString) { String url = request.getRequestURI(); String queryString = request.getQueryString(); if (!StringUtils.isEmpty(queryString)) { queryString = "?" + queryString; for (String pattern : excludeParameterPatterns) { queryString = queryString.replaceAll(pattern, ""); }//from www. j a v a2s .c o m if (queryString.startsWith("&")) { queryString = "?" + queryString.substring(1); } } if (!StringUtils.isEmpty(queryString) && needQueryString) { url = url + queryString; } return getBasePath(request) + url; }
From source file:co.com.ppit2.web.controller.handler.MyAccessDeniedHandler.java
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { String uri = request.getRequestURI(); String cPath = request.getContextPath(); int longCPath = cPath.length(); String pagSolicitada = uri.substring(longCPath); response.sendRedirect(accessDeniedUrl); request.getSession().setAttribute("pagSolicitada", pagSolicitada); }
From source file:com.cisco.ca.cstg.pdi.interceptor.LicensePresenceInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { boolean returnValue = false; if (request.getRequestURI() != null) { String requestString = request.getRequestURI().toString(); requestString = requestString.substring(requestString.indexOf('/', 1) + 1); int separatorIndex = requestString.indexOf('?'); requestString = separatorIndex > -1 ? requestString.substring(0, separatorIndex) : requestString; if (LicenseFileValidator.getInstance().licenseFileExists() || SKIP_REQUEST_LIST.contains(requestString)) { returnValue = true;/*from ww w. j av a 2 s.c o m*/ } else { response.sendRedirect("license.html"); returnValue = false; } } return returnValue; }
From source file:org.chos.transaction.passport.LoginInterceptor.java
/** * (Javadoc)/*w w w . ja v a 2s . com*/ * * @see org.springframework.web.servlet.HandlerInterceptor#preHandle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object) */ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception { String requestUrl = request.getRequestURI().replace(request.getContextPath(), ""); System.out.println(requestUrl); Session session = httpContextSessionManager.getSession(request); if (session != null) { String redirect = request.getParameter("redirect"); if (StringUtils.isBlank(redirect)) { redirect = redirectUrl; } response.sendRedirect(redirect); } return true; }
From source file:keywhiz.FileAssetServletTest.java
@Test public void notFoundRequest() throws Exception { File folder = tempDir.newFolder("notFoundRequestTest"); FileAssetServlet servlet = new FileAssetServlet(folder, "/ui/", "index.html"); HttpServletRequest request = mock(HttpServletRequest.class); HttpServletResponse response = mock(HttpServletResponse.class); when(request.getRequestURI()).thenReturn("/ui/non-existant"); servlet.doGet(request, response);/*from w w w . j ava 2 s .co m*/ verify(response).sendError(HttpStatus.SC_NOT_FOUND); }
From source file:com.erudika.para.security.OpenIDAuthFilter.java
/** * Handles an authentication request./*from w w w . j av a 2s. c o m*/ * @param request HTTP request * @param response HTTP response * @return an authentication object that contains the principal object if successful. * @throws IOException ex */ @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws IOException { final String requestURI = request.getRequestURI(); Authentication userAuth = null; User user = null; if (requestURI.endsWith(OPENID_ACTION)) { Authentication oidAuth = super.attemptAuthentication(request, response); if (oidAuth == null) { // hang on... redirecting to openid provider return null; } else { //success! user = (User) oidAuth.getPrincipal(); userAuth = new UserAuthentication(user); } } if (userAuth == null || user == null || user.getIdentifier() == null) { throw new BadCredentialsException("Bad credentials."); } else if (!user.isEnabled()) { throw new LockedException("Account is locked."); } return userAuth; }
From source file:com.hastybox.lesscss.compileservice.controller.spring.MappedSpringLessController.java
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String requestUri = request.getRequestURI(); LOGGER.debug("Handling request to URI {}" + requestUri); String lessPath = null;/* w w w . j a v a 2 s . c o m*/ for (Entry<Pattern, String> mappingEntry : mapping.entrySet()) { Matcher matcher = mappingEntry.getKey().matcher(requestUri); if (matcher.find()) { lessPath = mappingEntry.getValue(); LOGGER.debug("Matched {} to {}", requestUri, lessPath); break; } } if (lessPath != null) { compileLess(lessPath, response); } else { // send 404 if no match was found LOGGER.info("Could not match {}. Sending 404.", requestUri); response.sendError(404); } return null; }
From source file:com.headissue.pigeon.PigeonContainer.java
@Override public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { long dtStart = System.currentTimeMillis(); HttpServletRequest httpReq = (HttpServletRequest) req; if (log.isTraceEnabled()) { LogUtils.trace(log, "%s '%s'", httpReq.getMethod(), httpReq.getRequestURI()); Enumeration<String> en = httpReq.getHeaderNames(); while (en.hasMoreElements()) { String name = en.nextElement(); String value = httpReq.getHeader(name); LogUtils.trace(log, "request header '%s=%s'", name, value); }/*from ww w . j ava2 s.c om*/ LogUtils.trace(log, "locale=%s", req.getLocale()); } super.service(req, res); // how long? LogUtils.debug(log, "%s '%s' in msecs %s", httpReq.getMethod(), httpReq.getRequestURI(), System.currentTimeMillis() - dtStart); }