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.sivalabs.jcart.admin.security.PostAuthorizationFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
        throws ServletException, IOException {
    String uri = request.getRequestURI();
    if (!isIgnorableURI(uri)) {
        String menu = MenuConfiguration.getMatchingMenu(uri);
        request.setAttribute("CURRENT_MENU", menu);
    }/* w w w. j  a va  2  s. com*/
    chain.doFilter(request, response);
}

From source file:com.kdgregory.pathfinder.test.spring3.pkg2.ControllerB.java

@RequestMapping(value = "/bar.html", method = RequestMethod.GET)
protected ModelAndView getBar(HttpServletRequest request, HttpServletResponse response) throws Exception {
    ModelAndView mav = new ModelAndView("simple");
    mav.addObject("reqUrl", request.getRequestURI());
    mav.addObject("controller", getClass().getName());
    return mav;//w  ww .j  ava2s .  c  o  m
}

From source file:com.kdgregory.pathfinder.test.spring3.pkg2.ControllerB.java

@RequestMapping(value = "/baz.html", method = RequestMethod.POST)
protected ModelAndView setBaz(HttpServletRequest request, HttpServletResponse response) throws Exception {
    ModelAndView mav = new ModelAndView("simple");
    mav.addObject("reqUrl", request.getRequestURI());
    mav.addObject("controller", getClass().getName());
    return mav;/*from ww w  .j av a2 s . c o m*/
}

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

@RequestMapping(method = RequestMethod.GET, value = "/*/*/*/*")
void getArtifact(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String requestUri = request.getRequestURI();
    String[] uriComponents = requestUri.split("/");

    String repository = uriComponents[uriComponents.length - 4];
    String type = uriComponents[uriComponents.length - 3];
    String name = uriComponents[uriComponents.length - 2];
    String version = uriComponents[uriComponents.length - 1];

    InputStream artefact = this.repositoryManager.getArtifact(repository, type, name, version);
    if (artefact != null) {
        response.setContentType(ARTEFACT_CONTENT_TYPE);
        FileCopyUtils.copy(artefact, response.getOutputStream());
    } else {//from  w  ww.  j  a va 2s  . c  o m
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    }
}

From source file:uk.org.rbc1b.roms.controller.RequestLoggerInterceptor.java

@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
        Exception ex) throws Exception {
    LOGGER.info("Completed: {}", request.getRequestURI());
}

From source file:org.consultjr.mvc.service.AuthenticationInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object controller)
        throws Exception {
    String uri = request.getRequestURI();
    User user = (User) request.getSession().getAttribute("usuarioLogado");
    //Se Usuario esta logado
    if (user != null) {
        //return true;
        //Verifica se ele tem permissao para acessar a pagina
        user.setType(Type.ADMIN);
        if (uri.endsWith("/org.consultjr.EventsManagement") || uri.endsWith("loginForm")
                || uri.endsWith("doLogin")) {
            return true;
        }/* ww  w  .java  2 s. c o m*/
        if (rqAnalyser.checkPermission(user, request)) {
            return true;
        } else {
            //se nao tiver manda de volta pra tela inicial dele
            response.sendRedirect("/org.consultjr.EventsManagement/menu");
            return false;
        }
    } else {
        //se nao ta logado volta pra tela de login

        if (uri.endsWith("/org.consultjr.EventsManagement") || uri.endsWith("loginForm")
                || uri.endsWith("doLogin") || uri.endsWith("install")) {
            return true;
        }
        response.sendRedirect("/org.consultjr.EventsManagement/loginForm");
        response.sendRedirect("/loginForm");
        return false;
    }

}

From source file:com.sun.socialsite.web.filters.RedirectorFilter.java

private String getUrlAndQueryString(HttpServletRequest httpReq) {
    String uri = httpReq.getRequestURI();
    String query = httpReq.getQueryString();
    return (uri + ((query != null) ? ("?" + query) : ""));
}

From source file:com.consol.citrus.simulator.servlet.StaticResourceServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    Template template = compileHandlebarsTemplate(getTemplateName(req.getRequestURI()));

    Map<String, Object> model = new HashMap<String, Object>();
    model.put("contextPath", req.getContextPath());

    template.apply(Context.newContext(model), resp.getWriter());
}

From source file:com.sastix.cms.common.services.web.ExceptionHandlingController.java

@ExceptionHandler({ CommonException.class })
public void handleBadRequests(HttpServletRequest request, HttpServletResponse response, Exception e)
        throws IOException {
    LOG.error("Bad request: {} from {}, Exception: {} {}", request.getRequestURI(), request.getRemoteHost(),
            e.getStackTrace()[0].toString(), e.getLocalizedMessage());

    response.sendError(HttpStatus.BAD_REQUEST.value(), e.getLocalizedMessage());
}

From source file:io.seldon.api.interceptor.AuthorisationInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    final String requestURI = request.getRequestURI();
    logger.info("Interceptor for: " + requestURI);

    final Enumeration<String> headerNames = request.getHeaderNames();
    logger.debug("<Headers>");
    while (headerNames.hasMoreElements()) {
        final String header = headerNames.nextElement();
        logger.debug(header + " => " + request.getHeader(header));
    }/*from   w  w  w .ja  v a 2  s .  c o  m*/
    logger.debug("</Headers>");

    final String referrer = request.getHeader("Referer"); // sic.; incorrect spelling due to spec
    logger.info("Referrer: " + referrer);

    // Authorise on the basis of the referrer header...

    return super.preHandle(request, response, handler);
}