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:org.tangram.spring.MeasureTimeInterceptor.java

@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
        Exception ex) throws Exception {
    String thisURL = request.getRequestURI();
    if (!getFreeUrls().contains(thisURL)) {
        Long startTime = (Long) request.getAttribute("start.time");
        statistics.avg("page render time", System.currentTimeMillis() - startTime);
    } // if/*from w  w  w  .ja va  2s  .  c om*/
    super.afterCompletion(request, response, handler, ex);
}

From source file:com.glaf.shiro.filter.GlobalPermissionsAuthorizationFilter.java

@Override
public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
        throws IOException {
    HttpServletRequest req = (HttpServletRequest) request;
    Subject subject = getSubject(request, response);
    String uri = req.getRequestURI();

    String contextPath = req.getContextPath();

    int i = uri.indexOf(contextPath);
    if (i > -1) {
        uri = uri.substring(i + contextPath.length());
    }// ww w .j a va2  s .  c  o  m
    if (StringUtils.isBlank(uri)) {
        uri = "/";
    }
    boolean permitted = false;
    if ("/".equals(uri)) {
        permitted = true;
    } else {
        permitted = subject.isPermitted(uri);
    }

    return permitted;

}

From source file:org.eclipse.virgo.apps.repository.web.RepositoryController.java

@RequestMapping(method = RequestMethod.GET, value = "/*")
void getIndex(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String path = request.getRequestURI();
    String repository = path.substring(path.lastIndexOf('/') + 1);

    RepositoryIndex index = this.repositoryManager.getIndex(repository);
    if (index != null) {
        String indexETag = index.getETag();

        String eTagHeader = request.getHeader(IF_NONE_MATCH_HEADER_NAME);
        if (eTagHeader != null) {
            String[] eTags = eTagHeader.split(",");
            for (String eTag : eTags) {
                if (eTag.equals(indexETag)) {
                    response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                    return;
                }// w ww  .  j  a v a 2 s.c om
            }
        }

        response.setContentType(INDEX_CONTENT_TYPE);
        response.setContentLength(index.getLength());
        response.addHeader(ETAG_HEADER_NAME, index.getETag());

        FileCopyUtils.copy(index.getInputStream(), response.getOutputStream());
    } else {
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    }
}

From source file:org.codehaus.marmalade.msp.finder.FileBasedScriptFinder.java

public Reader getScript(HttpServletRequest request) throws IOException {
    validateState();/*  ww  w. j a va  2  s. c  om*/

    String path = request.getRequestURI();

    System.out.println("Request path: " + path);

    if (pathInterpreter != null) {
        path = pathInterpreter.interpret(path);
    }

    if (!path.startsWith("/")) {
        path = "/" + path;
    }

    System.out.println("Interpreted path: " + path);

    path = basePath + path;

    System.out.println("Full path: " + path);

    Reader result = null;
    if (appContext != null) {
        Resource scriptResource = appContext.getResource(path);
        result = new BufferedReader(new InputStreamReader(scriptResource.getInputStream()));
    } else {
        result = new BufferedReader(new FileReader(path));
    }

    System.out.println("Returning reader for file: " + path);

    return result;
}

From source file:com.ms.app.web.commons.pagecache.DefaultPageCache.java

/**
 * ??/*  www .  j  a va 2 s  . c  o  m*/
 * 
 * @param request
 * @return
 */
public boolean isSupport(HttpServletRequest request) {
    if (!isEnable()) {
        return false;
    }
    return isSupport(request.getRequestURI(), matchUrls);
}

From source file:com.evolveum.midpoint.web.security.MidPointAccessDeniedHandler.java

private boolean isLoginLogoutRequest(HttpServletRequest req) {
    if (!"post".equalsIgnoreCase(req.getMethod())) {
        return false;
    }/*from w  w  w .  j ava  2 s  . c o m*/

    String uri = req.getRequestURI();
    return createUri(req, "/j_spring_security_logout").equals(uri)
            || createUri(req, "/spring_security_login").equals(uri);
}

From source file:com.github.spring.mvc.util.handler.UriMatchingHandlerInterceptorInterceptor.java

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
    boolean proceed = false;

    for (Method method : HandlerInterceptor.class.getMethods()) {
        if (MethodUtils.isOverriden(method, invocation.getMethod())) {
            proceed = true;/*from  w w w. j a va2 s. c o  m*/
            break;
        }
    }

    if (proceed) {
        Includes includes = invocation.getThis().getClass().getAnnotation(Includes.class);
        Excludes excludes = invocation.getThis().getClass().getAnnotation(Excludes.class);

        String uri = null;
        for (Object argument : invocation.getArguments()) {
            if (argument instanceof HttpServletRequest) {
                HttpServletRequest request = (HttpServletRequest) argument;
                uri = request.getRequestURI();
                break;
            }
        }

        if (excludes != null) {
            for (String excludePath : excludes.value()) {
                if (HandlerUtils.servletUrlPatternMatch(excludePath, uri)) {
                    if (log.isTraceEnabled()) {
                        log.trace("Found matching exclude=[" + excludePath + "] for uri=[" + uri
                                + "]: halt processing");
                    }

                    return true;
                }
            }
        }

        if (includes != null) {
            for (String includePath : includes.value()) {
                if (HandlerUtils.servletUrlPatternMatch(includePath, uri)) {
                    if (log.isTraceEnabled()) {
                        log.trace("Found matching include=[" + includePath + "] for uri=[" + uri
                                + "]: continue processing");
                    }

                    return invocation.proceed();
                }
            }
        }

    }

    return invocation.proceed();
}

From source file:com.kdgregory.pathfinder.test.spring2.BarController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    Map<String, String> model = new HashMap<String, String>();
    model.put("reqUrl", request.getRequestURI());
    model.put("controller", getClass().getName());
    return new ModelAndView("simple", "data", model);
}

From source file:com.surevine.alfresco.audit.listeners.EditDiscussionTopicAuditEventListener.java

@Override
public boolean isEventFired(final HttpServletRequest request) {

    JSONObject json = parseJSONFromPostContent(request);
    if (json != null) {
        return (request.getRequestURI().contains(URI_DESIGNATOR) && json.has(AlfrescoJSONKeys.TITLE));
    }//from  w w  w  .ja v a  2s  .com

    return false;
}

From source file:com.qcadoo.view.internal.resource.module.UniversalResourceModule.java

@Override
public boolean serveResource(final HttpServletRequest request, final HttpServletResponse response) {
    Resource resource = getResourceFromURI(request.getRequestURI());
    if (resource != null && resource.exists()) {
        response.setContentType(getContentTypeFromURI(request));
        try {//from   w  ww  . j av a 2 s.c o m
            IOUtils.copy(resource.getInputStream(), response.getOutputStream());
        } catch (IOException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
        return true;
    } else {
        return false;
    }
}