Example usage for javax.servlet.http HttpServletRequest getContextPath

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

Introduction

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

Prototype

public String getContextPath();

Source Link

Document

Returns the portion of the request URI that indicates the context of the request.

Usage

From source file:br.com.insula.spring.security.janrain.Janrain.java

public String getTokenUrl(HttpServletRequest request) {
    return getTokenUrl(request, String.format("%s%s", request.getContextPath(), JANRAIN_URI));
}

From source file:com.trenako.web.tags.SpringTagSupport.java

@Override
protected int doStartTagInternal() throws Exception {
    init();/*from   w  ww  .j a v a 2 s.  com*/

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    String contextPath = request.getContextPath();

    return writeTagContent(pageContext.getOut(), contextPath);
}

From source file:com.salesmanager.core.security.JAASCustomerSecurityFilter.java

@Override
String getLogonPage(HttpServletRequest request) {
    return request.getContextPath() + "/signin.action";
}

From source file:com.googlecode.psiprobe.controllers.apps.AjaxReloadContextController.java

protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    if (!request.getContextPath().equals(contextName) && context != null) {
        try {//from w  ww  .j ava2  s  .co m
            logger.info(request.getRemoteAddr() + " requested RELOAD of " + contextName);
            context.reload();
        } catch (Throwable e) {
            logger.error(e);
            //
            // make sure we always re-throw ThreadDeath
            //
            if (e instanceof ThreadDeath) {
                throw (ThreadDeath) e;
            }
        }
    }
    return new ModelAndView(getViewName(), "available", Boolean
            .valueOf(context != null && getContainerWrapper().getTomcatContainer().getAvailable(context)));
}

From source file:info.rmapproject.webapp.utils.UrlPathHelperNonDecoding.java

@Override
public String getOriginatingServletPath(HttpServletRequest request) {
    String servletPath = request.getRequestURI().substring(request.getContextPath().length());
    return servletPath;
}

From source file:net.testdriven.psiprobe.controllers.apps.AjaxReloadContextController.java

protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    if (!request.getContextPath().equals(contextName) && context != null) {
        try {//w w w. j av a 2  s. c om
            logger.info(request.getRemoteAddr() + " requested RELOAD of " + contextName);
            context.reload();
        } catch (Throwable e) {
            logger.error(e);
            //
            // make sure we always re-throw ThreadDeath
            //
            if (e instanceof ThreadDeath) {
                throw (ThreadDeath) e;
            }
        }
    }
    return new ModelAndView(getViewName(), "available",
            Boolean.valueOf(context != null && context.getAvailable()));
}

From source file:io.github.microcks.web.filter.StaticResourcesFilter.java

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
    String contextPath = httpRequest.getContextPath();
    String requestURI = httpRequest.getRequestURI();
    requestURI = StringUtils.substringAfter(requestURI, contextPath);
    if (StringUtils.equals("/", requestURI)) {
        requestURI = "/index.html";
    }//w  ww.jav a  2s.c o  m
    String newURI = "/dist" + requestURI;
    log.debug("Dispatching to URI: {}", newURI);
    servletRequest.getRequestDispatcher(newURI).forward(servletRequest, servletResponse);
}

From source file:com.googlecode.psiprobe.controllers.apps.AjaxToggleContextController.java

protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    if (!request.getContextPath().equals(contextName) && context != null) {
        try {/*w ww  .  ja v  a 2  s.  c o m*/
            if (context.getAvailable()) {
                logger.info(request.getRemoteAddr() + " requested STOP of " + contextName);
                getContainerWrapper().getTomcatContainer().stop(contextName);
            } else {
                logger.info(request.getRemoteAddr() + " requested START of " + contextName);
                getContainerWrapper().getTomcatContainer().start(contextName);
            }
        } catch (Throwable e) {
            logger.error(e);
            //
            // make sure we always re-throw ThreadDeath
            //
            if (e instanceof ThreadDeath) {
                throw (ThreadDeath) e;
            }
        }
    }
    return new ModelAndView(getViewName(), "available", Boolean
            .valueOf(context != null && getContainerWrapper().getTomcatContainer().getAvailable(context)));
}

From source file:net.testdriven.psiprobe.controllers.apps.AjaxToggleContextController.java

protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    if (!request.getContextPath().equals(contextName) && context != null) {
        try {/*  w w  w  . j a v a  2  s. co  m*/
            if (context.getAvailable()) {
                logger.info(request.getRemoteAddr() + " requested STOP of " + contextName);
                getContainerWrapper().getTomcatContainer().stop(contextName);
            } else {
                logger.info(request.getRemoteAddr() + " requested START of " + contextName);
                getContainerWrapper().getTomcatContainer().start(contextName);
            }
        } catch (Throwable e) {
            logger.error(e);
            //
            // make sure we always re-throw ThreadDeath
            //
            if (e instanceof ThreadDeath) {
                throw (ThreadDeath) e;
            }
        }
    }
    return new ModelAndView(getViewName(), "available",
            Boolean.valueOf(context != null && context.getAvailable()));
}

From source file:com.orange.wro.taglib.tag.OptionalScriptTag.java

private void writeScript(PageContext context, StringBuilder builder, String path) throws IOException {

    if (!StringUtils.isEmpty(path)) {
        HttpServletRequest req = (HttpServletRequest) context.getRequest();
        String fullPath = req.getContextPath() + path;
        String out = String.format(WroTagLibConstants.JS_MARKUP, fullPath);
        builder.append(WroTagLibConstants.LESS_DEBUG_OPTIONS);
        builder.append(out);/*w w w.  j  a v a2 s . co m*/
    }
}