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:baggage.hypertoolkit.RouteFinder.java

public Supplier<RequestHandler> resolve(HttpServletRequest request) {
    String name = request.getRequestURI().replaceAll("^" + request.getServletPath() + "/", "").replaceAll("^/",
            "");/*from  ww w . j a  v a  2 s  . com*/

    for (String extension : StaticFileHandler.MIME_TYPES.keySet()) {
        if (name.endsWith(extension)) {
            return () -> new StaticFileHandler(webDir);
        }
    }

    if (StringUtils.isEmpty(name)) {
        return defaultHandler;
    }
    if (map.containsKey(name)) {
        return map.get(name);
    } else {
        Log.debug(this, "404: " + name);
        return () -> new FourOhFour();
    }
}

From source file:com.sourcesense.alfresco.opensso.AlfrescoShareFilter.java

private boolean isLogoutRequest(ServletRequest sreq) {
    HttpServletRequest req = (HttpServletRequest) sreq;
    if (req.getServletPath().contains("logout")) {
        return true;
    }/*w w  w . j  av  a2  s.  c  o m*/
    return false;
}

From source file:com.xhsoft.framework.common.interceptor.AccessInterceptor.java

/**
 * <p>Description:??????</p>
 * @param entRegNO   /*from  w ww .ja  v  a  2 s  .  co  m*/
 * @param proptity   
 * @return String
 * @author wenzhi
 * @version 1.0
 * @exception Exception
 */
public String intercept(ActionInvocation invocation) throws Exception {
    logger.debug("start access privilege check...");
    HttpServletRequest request = ServletActionContext.getRequest();
    String uri = request.getServletPath();
    String url = uri;
    String queryString = request.getQueryString();

    if (StringUtils.isNotEmpty(queryString)) {
        url = uri + "?" + queryString;
    }
    logger.debug(url);
    if (url.startsWith("/admin/purview/userinfo/login.action")
            || url.startsWith("/admin/purview/userinfo/logout.action")) {
        logger.debug("login/logout request,pass request");
        return invocation.invoke();
    } else {
        /*if (!LoginUtil.isLogin(request,"login")) {//?   
           logger.debug("not login request uri=" + url);
           logger.debug("not login access,take to login tip page");
           return "invalidLogin";
        }else {
           *//**???*//*
                                                                logger.debug("have login access,pass request");
                                                                return invocation.invoke();
                                                                }*/

        return invocation.invoke();
    }
}

From source file:org.zht.framework.filter.UserAccessLogFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    String requestUrl = httpRequest.getServletPath();

    if (isIgnorUrl(requestUrl)) {
        filterChain.doFilter(request, response);
        return;/* w  w  w.j  a  v  a 2s  .  c o m*/
    } //?
    OperationLog operationLog = LogUtil.genOperationLog(httpRequest);
    if (isPersistToDataBase) {
        if (operationLog != null) {
            try {
                operateLogService.$base_save(operationLog);
            } catch (Exception e) {

            }

        }
    }
    filterChain.doFilter(request, response);
}

From source file:com.dominion.salud.mpr.web.interceptors.SecurityInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
    if (!StringUtils.contains(request.getServletPath(), "services")) {
        if (request.getSession() != null && request.getSession().getAttribute("mpr.usuario") != null) {
            return true;
        } else {/*from   w w  w.  j a  v  a2s  .  co m*/
            throw new SesionExpiradaException("La sesion ha expirado");
        }
    } else {
        return true;
    }
}

From source file:me.j360.trace.autoconfiguration.ui.ZipkinUiAutoConfiguration.java

/**
 * This opts out of adding charset to png resources.
 *
 * <p>By default, {@linkplain CharacterEncodingFilter} adds a charset qualifier to all resources,
 * which helps, as javascript assets include extended character sets. However, the filter also
 * adds charset to well-known binary ones like png. This creates confusing content types, such as
 * "image/png;charset=UTF-8".//ww w . j a  v  a 2s.co m
 *
 * See https://github.com/spring-projects/spring-boot/issues/5459
 */
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public CharacterEncodingFilter characterEncodingFilter() {
    CharacterEncodingFilter filter = new CharacterEncodingFilter() {
        @Override
        protected boolean shouldNotFilter(HttpServletRequest request) {
            return request.getServletPath().endsWith(".png");
        }
    };
    filter.setEncoding("UTF-8");
    filter.setForceEncoding(true);
    return filter;
}

From source file:br.on.daed.services.filters.AllowCrossDomainAjax.java

@Override
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    String path = request.getServletPath();
    if (path.matches("^/astro/.*$")) {
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
    }//from   ww  w.  ja v  a2 s  . c o  m
    chain.doFilter(request, response);
}

From source file:com.apress.progwt.server.web.controllers.IndexController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse arg1)
        throws Exception {

    log.debug("SERVLET PATH: " + req.getServletPath() + " " + req.getPathInfo() + " " + req.getQueryString());

    Map<String, Object> model = getDefaultModel(req);

    // parameter may be on param line if we're redirect:ed here
    // (createUserController)
    model.put("message", req.getParameter("message"));

    model.put("frontPage", new FrontPageData(userService, schoolService));

    ModelAndView mav = new ModelAndView();
    mav.addAllObjects(model);//  w  w w.java  2 s.  c o m
    return mav;
}

From source file:psiprobe.controllers.BeanToXmlController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    String path = request.getServletPath();
    String internalPath = path.replaceAll(xmlMarker, "");

    Controller controller = (Controller) getApplicationContext().getBean(internalPath);
    if (controller != null) {
        ModelAndView modelAndView = controller.handleRequest(request, response);
        if (modelAndView.getModel() != null) {
            TransportableModel tm = new TransportableModel();
            tm.putAll(modelAndView.getModel());
            new XStream().toXML(tm, response.getWriter());
        }/*from   w  w  w  .  j a va2  s  .  c o  m*/
    }
    return null;
}

From source file:com.acc.storefront.util.CSRFHandlerInterceptor.java

protected boolean shouldCheckCSRFTokenForRequest(final HttpServletRequest request) {
    return ("POST").equalsIgnoreCase(request.getMethod()) && !isCSRFExemptUrl(request.getServletPath());
}