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:edu.cornell.mannlib.oce.filters.FakeLoginFilter.java

private boolean isImageRequest(HttpServletRequest req) {
    return req.getRequestURI().indexOf("images/") >= 0;
}

From source file:ua.yandex.shad.socnet.web.usermanager.AuthenticationInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    String uri = request.getRequestURI();
    //System.out.println(uri);

    if (!userManager.isLoggedIn()) {
        response.sendRedirect("loginpage");
        return false;
    }/*from  www  .  j a  v  a 2  s  . c  o m*/
    //System.out.println(userManager.getUser());

    return true;
}

From source file:com.thoughtworks.go.server.security.GoExceptionTranslationFilter.java

private boolean isJson(HttpServletRequest httpRequest) {
    return httpRequest.getRequestURI().endsWith(".json")
            && StringUtils.isBlank(httpRequest.getParameter("callback"));
}

From source file:com.thoughtworks.go.server.security.GoExceptionTranslationFilter.java

private boolean isJsonp(HttpServletRequest httpRequest) {
    return httpRequest.getRequestURI().endsWith(".json")
            && !StringUtils.isBlank(httpRequest.getParameter("callback"));
}

From source file:com.vaadin.tests.applicationservlet.VaadinRefreshServlet.java

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    if (request.getRequestURI().contains("/UIDL")) {
        InputStream loginHtml = request.getServletContext().getResourceAsStream("/statictestfiles/login.html");
        IOUtils.copy(loginHtml, response.getOutputStream());
        return;//from   w ww. j  a va 2  s  . com
    }
    super.service(request, response);
}

From source file:com.castlemock.web.basis.web.mvc.controller.ViewControllerAdvice.java

/**
 * Handles uncaught exceptions and creates an error view that will be displayed to the user.
 * @param request The request that originally caused the exception
 * @param exception The uncaught exception
 * @return Returns a view that displays the exception message
 *//*from   w  w  w .ja  v a 2s  . c  o  m*/
@ResponseBody
@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorViewHandler(HttpServletRequest request, Exception exception) {
    LOGGER.error("The following request failed: " + request.getRequestURI() + " (" + request.getMethod() + ")");
    LOGGER.error(exception.getMessage(), exception);
    ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(TITLE, "An error occurred");
    model.addObject(MESSAGE, exception.getMessage());
    return model;
}

From source file:com.r3bl.controller.LoginInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    String uri = request.getRequestURI();

    if (uri.contains("dashboard")) {
        Usuario u = (Usuario) request.getSession().getAttribute("usuarioLogado");
        if (u == null) {
            response.sendRedirect(request.getContextPath() + "/login");
            return false;
        }//w  w  w .j av  a2  s  .  c  om
    }
    return true;
}

From source file:id.go.kemdikbud.tandajasa.controller.PegawaiController.java

@RequestMapping("/pegawai/daftarpegawai")
public ModelMap unduhLaporan(HttpServletRequest request) {
    String uri = request.getRequestURI();
    String format = uri.substring(uri.lastIndexOf(".") + 1);

    ModelMap model = new ModelMap();
    model.put("format", format);
    model.put("tanggalCetak", new Date());
    model.put("dataSource", pegawaiDao.cariSemuaPegawai());

    return model;
}

From source file:com.tz.core.MyFreeMakerView.java

@Override
protected void exposeHelpers(Map model, HttpServletRequest request) throws Exception {
    model.put(CONTEXT_PATH, request.getContextPath());
    model.put(currentURL, request.getRequestURI());
    super.exposeHelpers(model, request);
}

From source file:interceptors.general.GeneralInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    if (request.getRequestURI().contains("all") || request.getRequestURI().contains("index")
            || request.getRequestURI().contains("Login") || request.getRequestURI().contains("Logout")
            || request.getRequestURI().contains("end")) {
        return true;
    }//from w  w  w  . j a v  a2 s .c  om
    if (request.getSession().getAttribute("loggedUser").toString().equals("admin")) {
        if (request.getRequestURI().contains("admin")) {
            return true;
        }
    } else {
        if (request.getRequestURI().contains("user") || request.getRequestURI().contains("post")) {
            return true;
        }
    }
    request.getSession().invalidate();
    response.sendRedirect("loginPage.html");
    return false;
}