List of usage examples for javax.servlet.http HttpServletRequest getRequestURI
public String getRequestURI();
From source file:com.googlecode.jsfFlex.phaseListener.JsfFlexHttpServicePhaseListener.java
public void afterPhase(PhaseEvent event) { FacesContext context = event.getFacesContext(); HttpServletRequest request = HttpServletRequest.class.cast(context.getExternalContext().getRequest()); String urlPath = request.getRequestURI(); Matcher jsfFlexHttpServiceRequestListenerUrlMatcher = JSF_FLEX_HTTP_SERVICE_REQUEST_LISTENER_URL_PATTERN .matcher(urlPath);/* w w w . j av a 2s. com*/ boolean matchFound = jsfFlexHttpServiceRequestListenerUrlMatcher.find(); if (matchFound) { processServiceRequest(context); } }
From source file:com.wisemapping.filter.BrowserSupportInterceptor.java
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception { final String requestUri = request.getRequestURI(); if (exclude != null && !exclude.contains(requestUri)) { final HttpSession session = request.getSession(false); // Try to loaded from the request ... SupportedUserAgent userAgent = null; if (session != null) { userAgent = (SupportedUserAgent) session.getAttribute(USER_AGENT); }/*from w w w.j av a 2s . com*/ // I could not loaded. I will create a new one... if (userAgent == null) { userAgent = SupportedUserAgent.create(request); if (session != null) { session.setAttribute(USER_AGENT, userAgent); } } // It's a supported browser ?. if (!userAgent.isBrowserSupported()) { throw new UnsupportedBrowserException(); } // Is a Explorer 9 or less without Google Chrome Frame ?. if (userAgent.needsGCF()) { throw new GoogleChromeFrameRequiredException(); } } return true; }
From source file:com.excella.deploy.agent.core.StatusServlet.java
/** * {@inheritDoc}// w w w. j a v a2 s. com */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.info("Recieved status request command over http [" + request.getRequestURI() + "]"); try { log.debug("Reporting Status..."); response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); PrintWriter writer = response.getWriter(); writer.println("<h1>Deploy Agent Status</h1>"); writer.println("<p>"); writer.println("Everything is Great!"); writer.println("</p>"); ((Request) request).setHandled(true); } catch (Exception e) { log.error("Failed to report Status.", e); } }
From source file:gov.nih.nci.caarray.web.filter.CacheControlFilter.java
/** * {@inheritDoc}/* w w w . j a v a 2 s .c o m*/ */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!(response instanceof HttpServletResponse)) { chain.doFilter(request, response); return; } HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; if (StringUtils.substringAfterLast(httpRequest.getRequestURI(), ".").equals(DYNAMIC_URL_EXTENSION)) { if (!request.isSecure()) { // workaround for IE files bug http://support.microsoft.com/kb/812935 httpResponse.addHeader("Cache-control", "no-cache"); httpResponse.addHeader("Pragma", "no-cache"); } httpResponse.addIntHeader("Expires", 0); } chain.doFilter(request, response); }
From source file:com.bstek.dorado.web.resolver.WebContextSupportedController.java
/** * URI?ContentPathURI/* w w w . jav a 2s.co m*/ */ protected String getRelativeRequestURI(HttpServletRequest request) throws UnsupportedEncodingException { String uri = (String) request.getAttribute("originalUrlPath"); if (uri == null) { uri = request.getRequestURI().substring(getContextPath(request).length()); } uri = StringUtils.replaceChars(URLDecoder.decode(uri, Configure.getString("view.uriEncoding")), ESCAPED_PATH_DELIM, PathUtils.PATH_DELIM); if (uri.length() > 1 && uri.charAt(0) == PathUtils.PATH_DELIM) { uri = uri.substring(1); } return uri; }
From source file:com.redhat.rhn.frontend.security.BaseAuthenticationService.java
protected boolean requestPostCsfrWhitelist(final HttpServletRequest request) { return CollectionUtils.exists(getPostUnprotectedURIs(), new Predicate() { public boolean evaluate(Object uri) { return request.getRequestURI().startsWith(uri.toString()); }/*from w ww . jav a 2s . c o m*/ }); }
From source file:gov.nih.nci.firebird.web.interceptor.FirebirdShowSplashPageInterceptor.java
private String getTargetUrl() { HttpServletRequest request = ServletActionContext.getRequest(); StringBuffer targetUrl = new StringBuffer(request.getRequestURI()); if (request.getQueryString() != null) { targetUrl.append('?'); targetUrl.append(request.getQueryString()); }/* w w w .j a v a2 s . co m*/ return targetUrl.toString(); }
From source file:ch.newscron.newscronjsp.ReferralSignUpServlet.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {//from w ww .ja v a 2 s .c om String[] urlPartsPath = request.getRequestURI().split("/"); String encodedDataString = urlPartsPath[urlPartsPath.length - 1]; String decodedDataString = Encryption.decode(encodedDataString); if (decodedDataString != null) { JSONParser parser = new JSONParser(); JSONObject decodedJSON = (JSONObject) parser.parse(decodedDataString); String dateValidity = (String) decodedJSON.get("val"); if (isDateValid(dateValidity)) { // Date validity not expired & not null from decoding URL String rewardNewUser = (String) decodedJSON.get("rew2"); String signupPageReferral = "%s/%s"; signupPageReferral = String.format(signupPageReferral, encodedDataString, Base64.encodeBase64URLSafeString(rewardNewUser.getBytes())); signupPage += signupPageReferral; } } } catch (Exception ex) { Logger.getLogger(ShortUrlCreator.class.getName()).log(Level.SEVERE, null, ex); } finally { response.sendRedirect(signupPage); } }
From source file:com.lemania.sis.server.servlet.GcsServlet.java
private GcsFilename getFileName(HttpServletRequest req) { ////from w w w .j av a 2s.co m String[] splits = req.getRequestURI().split("/", 4); if (!splits[0].equals("") || !splits[1].equals("gcs")) { throw new IllegalArgumentException( "The URL is not formed as expected. " + "Expecting /gcs/<bucket>/<object>"); } // AppIdentityService appIdentity = AppIdentityServiceFactory.getAppIdentityService(); String filename; String fullPath = splits[3]; int startIndex = (fullPath.indexOf('\\') >= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/')); if (startIndex > -1) { filename = fullPath.substring(startIndex); if (filename.indexOf('\\') == 0 || filename.indexOf('/') == 0) { filename = filename.substring(1); } } else { filename = fullPath; } // return new GcsFilename( appIdentity.getDefaultGcsBucketName() , filename ); return new GcsFilename(splits[2], splits[3]); }
From source file:cn.com.esrichina.gcloud.commons.LicenseFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String url = request.getRequestURI(); Boolean result = matchExcludePatterns(url); if (result) { filterChain.doFilter(request, response); return;//from w ww . j a va2 s. co m } if (licenceContext.getIsAuthorized()) { doFilter(request, response, filterChain); } else { response.setContentType("text/json;charset=UTF-8"); // TODO ajax Json???HTTP? PrintWriter writer = response.getWriter(); RestResponse res = new RestResponse(false, licenceContext.getReason()); ObjectMapper mapper = new ObjectMapper(); String json = ""; try { json = mapper.writeValueAsString(res); } catch (JsonProcessingException e) { e.printStackTrace(); } writer.print(json); writer.close(); } }