Example usage for javax.servlet.http HttpServletRequest getServletPath

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

Introduction

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

Prototype

public String getServletPath();

Source Link

Document

Returns the part of this request's URL that calls the servlet.

Usage

From source file:com.fota.fota3g.serviceMgt.controller.AccountPermissionsMgtCTR.java

/**
 * dmRetry View//from   ww  w . j  av a  2s  . c  o m
 * @param request
 * @param model
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/accountPermissionsMgtView")
public String getView(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
    logger.warn("#############accountPermissionsMgtView################");
    if (!request.getServletPath().equals("/commonServiceMgt/managementMgt/accountPermissionsMgtView")) {
        response.setStatus(403);
        return "redirect:/lresources/errorPage.jsp";
    }

    return "fota3g/managementMgt/accountPermissionsMgtView";
}

From source file:com.yahoo.dba.perf.myperf.springmvc.SigninController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse resp)
        throws Exception {
    logger.info("receive url path: " + request.getContextPath() + "," + request.getRequestURI() + ", "
            + request.getServletPath() + ", parameters: " + request.getQueryString());
    boolean failed = false;
    String username = request.getParameter("name");
    if (username != null) {
        username = username.trim().toLowerCase();
        //find the user from the system cache
        AppUser appUser = this.frameworkContext.getAuth().findUserByName(username);

        //sign in process
        boolean authed = this.frameworkContext.getAuth().login(appUser, request);

        if (authed)//display
        {//w w  w .j a  va  2 s  .  c o m
            String view = getLoginSuccessView();
            //if admin user, and setup not done yet, send to setup.
            if (appUser.isAdminUser() && !frameworkContext.getMyperfConfig().isConfigured())
                view = this.getSetupView();
            logger.info(appUser.getName() + " login, redirect to " + view);
            return new ModelAndView(new RedirectView(view));
        } //if(appUser!=null && appUser.match(request.getParameter("pd"))
        else {
            failed = true;
        }
    } //if(username!=null)

    //not authenticated? Try again
    //TODO add retry count
    long server_ts = System.currentTimeMillis();
    int seed = (int) (Math.random() * Integer.MAX_VALUE);
    ModelAndView mv = new ModelAndView(getLoginFormView());
    mv.addObject("name", username);
    if (failed)
        mv.addObject("message", DEFAULT_ERROR);
    mv.addObject("help_key", "start");
    mv.addObject("server_ts", server_ts);
    mv.addObject("ars", seed);//ars: authentication random seed
    //add store them in session
    request.getSession(true).setAttribute(AppUser.SERVER_TS, new Long(server_ts));
    request.getSession().setAttribute(AppUser.RANDOM_SEED, new Integer(seed));

    return mv;
}

From source file:com.razorfish.controllers.misc.StoreSessionController.java

protected String getReturnRedirectUrlForUrlEncoding(final HttpServletRequest request, final String old,
        final String current) {
    String referer = StringUtils.remove(request.getRequestURL().toString(), request.getServletPath());
    if (!StringUtils.endsWith(referer, "/")) {
        referer = referer + "/";
    }//from w  w w.j  a  v  a 2s  . c  om
    if (referer != null && !referer.isEmpty() && StringUtils.contains(referer, "/" + old + "/")) {
        return REDIRECT_PREFIX + StringUtils.replace(referer, "/" + old + "/", "/" + current + "/");
    }
    return REDIRECT_PREFIX + referer;
}

From source file:it.volaconnoi.servlet.BookingServlet.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request/*ww w  . ja  va2  s.  c o  m*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String userPath = request.getServletPath();

    session = request.getSession(true);

    if (userPath.equals("/booking")) {
        String route_id = request.getParameter("id");

        session.setAttribute("route", routeManagerBean.getRouteById(route_id));

        if (request.getUserPrincipal() != null) {
            UserCredential user = userManagerBean.getUserByUsername(request.getUserPrincipal().getName());

            session.setAttribute("user", user);
        }

        request.setAttribute("CountriesList", countryFacade.findAll());

        request.setAttribute("tax", PricerBeanInterface.TAX);

        request.getRequestDispatcher("/WEB-INF/view/booking/booking.jsp").forward(request, response);
    }
}

From source file:com.streamsets.pipeline.stage.origin.httpserver.PushHttpReceiver.java

protected Map<String, String> getCustomHeaderAttributes(HttpServletRequest req) {
    Map<String, String> customHeaderAttributes = new HashMap<>();
    customHeaderAttributes.put(PATH_HEADER, StringUtils.stripToEmpty(req.getServletPath()));
    customHeaderAttributes.put(QUERY_STRING_HEADER, StringUtils.stripToEmpty(req.getQueryString()));
    customHeaderAttributes.put(METHOD_HEADER, StringUtils.stripToEmpty(req.getMethod()));
    customHeaderAttributes.put(REMOTE_HOST, StringUtils.stripToEmpty(req.getRemoteHost()));
    Enumeration<String> headerNames = req.getHeaderNames();
    if (headerNames != null) {
        while (headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();
            customHeaderAttributes.put(headerName, req.getHeader(headerName));
        }/*from www . j av a  2s  .  c  om*/
    }

    return customHeaderAttributes;
}

From source file:io.neba.core.selftests.SelftestConsolePlugin.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    String suffix = substringAfter(req.getRequestURI(), req.getServletPath() + "/" + getLabel());
    if (!isBlank(suffix) && suffix.startsWith("/run/")) {
        runTest(suffix.substring(4), res);
        return;// ww w.j a  v a  2s . c o m
    }
    if (!isBlank(suffix) && suffix.equals("/run.xml")) {
        runAll(res);
        return;
    }
    super.doGet(req, res);
}

From source file:gov.nih.nci.ncicb.tcga.dcc.common.web.StaticContentServlet.java

protected long getLastModified(HttpServletRequest request) {
    if (log.isDebugEnabled()) {
        log.debug("Checking last modified of resource: " + request.getServletPath() + request.getPathInfo());
    }/*from   w ww. j a  v  a2  s  . com*/
    URL[] resources;
    try {
        resources = getRequestResourceURLs(request);
    } catch (MalformedURLException e) {
        return -1;
    }
    if (resources == null || resources.length == 0) {
        return -1;
    }
    long lastModified = -1;
    for (int i = 0; i < resources.length; i++) {
        URLConnection resourceConn;
        try {
            resourceConn = resources[i].openConnection();
        } catch (IOException e) {
            return -1;
        }
        if (resourceConn.getLastModified() > lastModified) {
            lastModified = resourceConn.getLastModified();
        }
    }
    return lastModified;
}

From source file:cn.guoyukun.spring.web.interceptor.SetCommonDataInterceptor.java

private boolean isExclude(final HttpServletRequest request) {
    if (excludeUrlPatterns == null) {
        return false;
    }/*  w ww  .ja  va 2 s  .  c  o  m*/
    for (String pattern : excludeUrlPatterns) {
        if (pathMatcher.match(pattern, request.getServletPath())) {
            return true;
        }
    }
    return false;
}

From source file:AIR.Common.Web.Session.CaseInsensitiveFileNameFilter.java

@Override
public void doFilter(ServletRequest wrappedRequest, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) wrappedRequest;
    String servletPath = request.getServletPath();
    String requestedPath = servletPath;

    boolean remapped = false;
    boolean needsSeparateRequestDispatcher = false;

    // first do extensions mapping. this way if we need to take care of casing
    // we will do that in the later step.
    _Ref<String> extensionMappedString = new _Ref<String>();
    if (getExtensionRemap(servletPath, extensionMappedString)) {
        servletPath = extensionMappedString.get();
        remapped = needsSeparateRequestDispatcher = true;
    }/*from ww w  .  j a  v  a  2  s.co  m*/
    String remappedServletPath = servletPath;

    // now we can do case insensitive path name mapping.
    if (_pathMap.containsKey(servletPath)) {
        remappedServletPath = _pathMap.get(servletPath);
        remapped = true;
    } else if (isMatchForRewriting(servletPath)) {
        remappedServletPath = remapUri(servletPath);
        if (!StringUtils.equals(remappedServletPath, servletPath)) {
            _pathMap.put(servletPath, remappedServletPath);
            remapped = true;
        }
    }

    if (remapped) {
        final String remappedServletPathFinal = remappedServletPath;
        HttpServletRequestWrapper modifiedHttpRequest = new HttpServletRequestWrapper(request) {
            @Override
            public String getServletPath() {
                return remappedServletPathFinal;
            }

            @Override
            public String getRequestURI() {
                return Path.combine(Server.getContextPath(), remappedServletPathFinal, "/");
            }

        };
        request = modifiedHttpRequest;
        if (needsSeparateRequestDispatcher) {
            // Sajib/Shiva: This is the only way to handle aspx to xhtml
            // transformations where
            // the xhtml is a real JSF page but this may be expensive as we may
            // already have gone
            // down other filtering chains. We are doing this as a last resort.
            _logger.warn(String.format(
                    "Redispatching as there was an extension transformation. Original URI %s. New URI %s",
                    requestedPath, remappedServletPath));
            request.getRequestDispatcher(request.getRequestURI()).forward(request, response);
        }
    }

    chain.doFilter(request, response);
}

From source file:com.fota.firmMgt.controller.FirmRegiCTR.java

/**
 *  ?/*from   w ww.  j  ava2  s. c  o  m*/
 * @return
 */
@RequestMapping(value = "/regiView")
public String firmRegiView(HttpServletRequest request, HttpServletResponse response) throws Exception {
    if (!request.getServletPath().equals("/commonDevice/firmRegiMgt/regiView")) {
        response.setStatus(403);
        return "redirect:/lresources/errorPage.jsp";
        //         return null;
    }

    return "firmMgt/firmRegiView";
}