Example usage for javax.servlet.http HttpServletRequest getRequestURI

List of usage examples for javax.servlet.http HttpServletRequest getRequestURI

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getRequestURI.

Prototype

public String getRequestURI();

Source Link

Document

Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.

Usage

From source file:com.threewks.thundr.view.negotiating.strategy.FileExtensionNegotiationStrategy.java

@Override
public Negotiator<?> findNegotiator(HttpServletRequest req, NegotiatingView view,
        ViewNegotiatorRegistry viewNegotiatorRegistry) {
    String requestUri = req.getRequestURI();
    String extension = StringUtils.trimToEmpty(StringUtils.substringAfterLast(requestUri, "."));
    String mimeType = MimeTypes.lookupMimeType(extension);
    return viewNegotiatorRegistry.getNegotiator(mimeType);
}

From source file:edu.uiowa.icts.filter.IctsSecurityFilter.java

/** {@inheritDoc} */
@Override/* ww  w . j  a  v  a2s.  co  m*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest servletRequest = (HttpServletRequest) request;

    log.debug("filtering request " + servletRequest.getRequestURI());

    //      ServletContext sc = getServletContext();
    //      Enumeration names = sc.getInitParameterNames();
    //      while( names.hasMoreElements() ){
    //         log.debug(names.nextElement());
    //      }

    chain.doFilter(request, response);
}

From source file:org.openrepose.filters.versioning.domain.VersionedRequest.java

private String removeVersionPrefix(HttpServletRequest request, String version) {
    if (request.getRequestURI().charAt(0) != '/') {
        throw new IllegalArgumentException(
                "Request URI must be a URI with a root reference - i.e. the URI must start with '/'");
    }/*w w  w.j a  v  a 2s  . c o m*/

    final String uri = StringUriUtilities.formatUri(request.getRequestURI());
    final String formattedVersion = StringUriUtilities.formatUri(version);

    if (formattedVersion.length() == 1) {
        return uri;
    }

    final String containedVersion = formattedVersion + "/";

    final int start = uri.indexOf(containedVersion);

    if (start >= 0) {
        return uri.replaceFirst(containedVersion, "/");
    } else if (uri.endsWith(formattedVersion)) {
        return uri.replace(formattedVersion, "/");
    }

    return uri;
}

From source file:name.martingeisse.servlet_httpclient.sidekicks.fakecdn.FakeCdnFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    String uri = httpRequest.getRequestURI();
    if (uri.startsWith(URI_PREFIX)) {
        String key = uri.substring(URI_PREFIX.length() - 1);
        doCdn(httpRequest, response, key);
    } else {//from www  .j av a 2s.  c  o  m
        filterChain.doFilter(request, response);
    }
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractStaticPagesController.java

@RequestMapping(value = { "/errors/*" })
public ModelAndView handle(HttpServletRequest request) {
    ModelAndView viewData = new ModelAndView();
    viewData.addObject("uri", request.getRequestURI());
    viewData.addObject("ref", request.getHeader("Referer"));
    return viewData;
}

From source file:es.osoco.grails.plugins.otp.access.InterceptUrlMapMultipleVoterFilterInvocationDefinition.java

@Override
protected String determineUrl(final FilterInvocation filterInvocation) {
    HttpServletRequest request = filterInvocation.getHttpRequest();
    String requestUrl = request.getRequestURI().substring(request.getContextPath().length());
    return lowercaseAndStripQuerystring(requestUrl);
}

From source file:net.mindengine.blogix.web.BlogixServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) {
    String uri = req.getRequestURI();
    try {/*from   www.ja v a  2  s . c om*/
        res.setStatus(200);
        String contentType = findContentTypeFor(uri);
        if (contentType != null) {
            res.setContentType(contentType);
        }
        blogix.processUri(uri, res.getOutputStream());
    } catch (Throwable e) {
        res.setStatus(400);
        printResponseText(res, ExceptionUtils.getMessage(e) + "\n" + ExceptionUtils.getStackTrace(e));
    }
}

From source file:com.nkapps.billing.configs.LoginInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws IOException {

    String uri = request.getRequestURI();
    if (!uri.startsWith("/auth")) {
        if (!authService.isAuthenticated()) {
            response.sendRedirect("/auth/login");
            return false;
        }//w  w  w  .j ava  2  s . c om
    }
    return true;
}

From source file:net.acesinc.convergentui.ConvergentUIRequestFilter.java

@Override
public Object run() {
    //First we need to build the correct URL
    RequestContext ctx = RequestContext.getCurrentContext();
    HttpServletRequest req = ctx.getRequest();

    String path = req.getRequestURI();

    String location = path.substring("/cui-req://".length());
    log.debug("RequestFilter for [ " + location + " ] in process");

    RequestContext context = RequestContext.getCurrentContext();
    ContentResponse response = contentManager.getContentFromService(location, location, false, context);

    MimeType type = response.getContentType();

    addResponseHeaders();// w  w w  . j a  v a  2 s. co  m

    if (!response.isError()) {
        Object resp = response.getContent();
        try {

            if (String.class.isAssignableFrom(resp.getClass())) {
                writeResponse((String) resp, type);
            } else if (BufferedImage.class.isAssignableFrom(resp.getClass())) {
                writeResponse((BufferedImage) resp, response.getContentType());
            } else if (/*Map.class.isAssignableFrom(resp.getClass()) &&*/ type.getSubtype().contains("json")) {
                writeResponse(mapper.writeValueAsString(resp), type);
            } else {

                log.warn("Unknown response type [ " + response.getContentType()
                        + " ] that we can't handle yet. Content is of type: " + resp.getClass());
            }
        } catch (Exception ex) {
            log.error("Error writing response", ex);
        }
    }
    return null;

}

From source file:com.esd.ps.interceptor.LoginInterceptor.java

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) {
    logger.debug(request.getRequestURI());
    if (request.getRequestURI().indexOf("/security") != -1) {
        Object obj = request.getSession().getAttribute(Constants.USER_ID);
        if (obj == null) {
            PrintWriter out = null;
            try {
                out = response.getWriter();
                StringBuilder builder = new StringBuilder();
                builder.append("<script type=\"text/javascript\" charset=\"UTF-8\">");
                builder.append("window.top.location.href='");
                builder.append("/ps/login");
                builder.append("';");
                builder.append("</script>");
                out.print(builder.toString());
                out.close();/*from ww  w . ja  v  a2 s  .  c o  m*/
                return false;
            } catch (IOException e) {
                logger.error(e.getMessage());
            } finally {
                if (out != null) {
                    out.close();
                }
            }

        }
    }
    return true;
}