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:com.atlassian.jira.web.action.setup.SetupSharedVariables.java

public String getBaseUrl() {
    final HttpServletRequest request = servletVariables.getHttpRequest();

    return request.getScheme() + "://localhost:" + request.getLocalPort() + request.getContextPath();
}

From source file:com.epam.cme.storefront.security.cookie.EnhancedCookieGenerator.java

/**
 * /* www  . j av a  2s .c o  m*/
 * Sets dynamically the {@link Cookie#setPath(String)} value using available
 * {@link HttpServletRequest#getContextPath()}.
 */
protected void setEnhancedCookiePath(final HttpServletRequest request, final Cookie cookie) {
    if (!canUseDefaultPath()) {
        cookie.setPath(request.getContextPath());
    }
}

From source file:com.erudika.para.security.OpenIDAuthFilter.java

/**
 * Default constructor./*from  www .ja  va  2s. com*/
 * @param defaultFilterProcessesUrl the url of the filter
 */
public OpenIDAuthFilter(final String defaultFilterProcessesUrl) {
    setRequiresAuthenticationRequestMatcher(new RequestMatcher() {
        public boolean matches(HttpServletRequest request) {
            String uri = request.getRequestURI();
            boolean matches;
            if ("".equals(request.getContextPath())) {
                matches = uri.endsWith(defaultFilterProcessesUrl);
            } else {
                matches = uri.endsWith(request.getContextPath() + defaultFilterProcessesUrl);
            }
            return matches;
        }
    });
}

From source file:org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationEntryPoint.java

protected void commenceLoginRedirect(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    String contextAwareLoginUri = request.getContextPath() + loginUri;
    log.debug("Redirecting to login URI {}", contextAwareLoginUri);
    response.sendRedirect(contextAwareLoginUri);
}

From source file:org.openmrs.module.vcttrac.web.controller.VCTClientSearchController.java

/**
 * @see org.springframework.web.servlet.mvc.ParameterizableViewController#handleRequestInternal(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 *///ww  w.  j a  va 2  s.  c om
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    if (Context.getAuthenticatedUser() == null)
        return new ModelAndView(new RedirectView(request.getContextPath() + "/login.htm"));

    ModelAndView mav = new ModelAndView();
    mav.setViewName(getViewName());

    return mav;
}

From source file:org.sakaiproject.imagegallery.web.MultiFileUploaderController.java

public void multiFileUpload(HttpServletRequest request, HttpServletResponse response) throws Exception {
    if (log.isInfoEnabled())
        log.info("req contextPath=" + request.getContextPath() + ", pathInfo=" + request.getPathInfo()
                + ", query=" + request.getQueryString() + ", URI=" + request.getRequestURI() + ", URL="
                + request.getRequestURL() + ", servlet=" + request.getServletPath());
    if (request instanceof MultipartHttpServletRequest) {
        String newImageId = storeNewImage((MultipartHttpServletRequest) request);
        response.setContentType("text/plain");
        PrintWriter responseWriter = response.getWriter();
        responseWriter.print(newImageId);
        responseWriter.close();//  w  w  w. j a  v  a2s .  c  o m
    }
}

From source file:net.sourceforge.subsonic.controller.HLSController.java

private String getContextPath(HttpServletRequest request) {
    String contextPath = request.getContextPath();
    if (StringUtils.isEmpty(contextPath)) {
        contextPath = "/";
    } else {// ww w.j av a  2 s .co  m
        contextPath += "/";
    }
    return contextPath;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.login.LoginTemplateHelper.java

/** What's the URL for this servlet? */
private String getAuthenticateUrl(HttpServletRequest request) {
    String contextPath = request.getContextPath();
    String urlParams = "?login=block";
    return contextPath + "/authenticate" + urlParams;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.login.LoginTemplateHelper.java

/** What's the URL for this servlet, with the cancel parameter added? */
private String getCancelUrl(HttpServletRequest request) {
    String contextPath = request.getContextPath();
    String urlParams = "?login=block&cancel=true";
    return contextPath + "/authenticate" + urlParams;
}

From source file:org.sventon.appl.ConfigAuthorizationFilter.java

private void redirectToLoginPage(HttpServletRequest request, HttpServletResponse response) throws IOException {
    logger.debug("Login required for editing config");
    response.sendRedirect(request.getContextPath() + "/repos/configlogin");
}