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.googlesource.gerrit.plugins.github.oauth.OAuthGitFilter.java

private URI getRequestUrlWithAlternatePath(HttpServletRequest httpRequest, String alternatePath)
        throws MalformedURLException {
    URL originalUrl = new URL(httpRequest.getRequestURL().toString());
    String contextPath = httpRequest.getContextPath();
    return URI.create(originalUrl.getProtocol() + "://" + originalUrl.getHost() + ":" + getPort(originalUrl)
            + contextPath + alternatePath);
}

From source file:edu.indiana.d2i.sloan.ui.LoginAction.java

/**
 * get server context/*  w w  w .j  a  v a 2s .c o m*/
 * 
 * @return
 */
private String getServerContext() {
    HttpServletRequest request = getServletRequest();
    final StringBuilder serverPath = new StringBuilder();
    serverPath.append(request.getScheme() + "://");
    serverPath.append(request.getServerName());
    if (request.getServerPort() != 80) {
        serverPath.append(":" + request.getServerPort());
    }
    serverPath.append(request.getContextPath());
    return serverPath.toString();
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.security.StorefrontAuthenticationSuccessHandler.java

protected void invalidateSession(final HttpServletRequest request, final HttpServletResponse response)
        throws IOException {
    SecurityContextHolder.getContext().setAuthentication(null);
    request.getSession().invalidate();/*from  w w  w  .j ava  2s .  c  om*/
    response.sendRedirect(request.getContextPath());
}

From source file:com.camel.framework.tag.ScriptTag.java

/**
 * ?????Coogle Minify?,??/*w  w w  . j av a 2 s . c  o m*/
 */
private void parse() {
    StringBuffer sb = new StringBuffer();

    // jspJspWriter
    JspWriter out = this.pageContext.getOut();

    // environmentConfig.xml?????value
    String resourcesUrl = null;
    if (null != ConfigParamMap.getConfigParamMap()) {
        ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_URL);
    }

    // ?null??URL
    if (null == resourcesUrl) {
        HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
        resourcesUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
                + request.getContextPath();
    }

    /**
     * ?environmentConfig.xml?resources_merger
     * ?jscss?,Ygoogle minify N?
     */
    String resourcesMerger = null;
    if (null != ConfigParamMap.getConfigParamMap()) {
        ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_MERGER);
    }
    if (ITagBasic.USER_MINIFY_CODE.equals(resourcesMerger)) {
        // ?? Minify?script??
        parseToMinifyStyle(sb, resourcesUrl, out);
    } else {
        // ??? Minify?script??
        parseToConventionalStyle(sb, resourcesUrl, out);
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.filters.URLRewritingHttpServletResponse.java

public URLRewritingHttpServletResponse(HttpServletResponse response, HttpServletRequest request,
        ServletContext context) {// ww  w. j  ava 2 s .  c om
    super(response);
    this._response = response;
    this._context = context;
    this.wadf = ModelAccess.on(context).getWebappDaoFactory();
    this.contextPathDepth = slashPattern.split(request.getContextPath()).length - 1;
}

From source file:module.regulation.dispatch.presentationTier.RegulationDispatchAction.java

private String generateLinkForView(HttpServletRequest request, RegulationDispatchWorkflowMetaProcess entry) {
    String contextPath = request.getContextPath();
    String realLink = contextPath + String
            .format("/regulationDispatch.do?dispatchId=%s&method=viewDispatch", entry.getExternalId());
    realLink += String.format("&%s=%s", GenericChecksumRewriter.CHECKSUM_ATTRIBUTE_NAME,
            GenericChecksumRewriter.calculateChecksum(realLink, request.getSession()));

    return realLink;
}

From source file:module.regulation.dispatch.presentationTier.RegulationDispatchAction.java

private String generateLinkForEdition(HttpServletRequest request, RegulationDispatchWorkflowMetaProcess entry) {
    String contextPath = request.getContextPath();
    String realLink = contextPath + String
            .format("/createRegulationDispatch.do?dispatchId=%s&method=prepareEdit", entry.getExternalId());
    realLink += String.format("&%s=%s", GenericChecksumRewriter.CHECKSUM_ATTRIBUTE_NAME,
            GenericChecksumRewriter.calculateChecksum(realLink, request.getSession()));

    return realLink;
}

From source file:org.jtwig.functions.SpringFunctions.java

@JtwigFunction(name = "asset")
public String asset(HttpServletRequest request, @Parameter String input)
        throws AssetResolveException, FunctionException {
    if (assetResolver == null)
        throw new FunctionException("In order to use the asset function, a bean of type "
                + AssetResolver.class.getName() + " must be configured");
    return new UrlPath().append(request.getContextPath()).append(assetResolver.resolve(input)).toString();
}

From source file:pivotal.au.se.gemfirexdweb.controller.CreateSynonymController.java

@RequestMapping(value = "/createsynonym", method = RequestMethod.GET)
public String createType(Model model, HttpServletResponse response, HttpServletRequest request,
        HttpSession session) throws Exception {

    if (session.getAttribute("user_key") == null) {
        logger.debug("user_key is null new Login required");
        response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
        return null;
    } else {// ww w. ja  v  a 2s.c  om
        Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key"));
        if (conn == null) {
            response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
            return null;
        } else {
            if (conn.isClosed()) {
                response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
                return null;
            }
        }

    }

    logger.debug("Received request to create a new synonym");

    TableDAO tableDAO = GemFireXDWebDAOFactory.getTableDAO();
    ViewDAO viewDAO = GemFireXDWebDAOFactory.getViewDAO();

    List<View> views = viewDAO.retrieveViewList((String) session.getAttribute("schema"), null,
            (String) session.getAttribute("user_key"));

    model.addAttribute("views", views);

    List<Table> tbls = tableDAO.retrieveTableList((String) session.getAttribute("schema"), null,
            (String) session.getAttribute("user_key"), "ORDINARY");

    List<Table> tblsHDFS = tableDAO.retrieveTableList((String) session.getAttribute("schema"), null,
            (String) session.getAttribute("user_key"), "HDFS");

    tbls.addAll(tblsHDFS);

    model.addAttribute("tables", tbls);

    model.addAttribute("synonymAttribute", new NewSynonym());
    model.addAttribute("objectName", request.getParameter("objectName"));

    // This will resolve to /WEB-INF/jsp/create-synonym.jsp
    return "create-synonym";
}

From source file:module.regulation.dispatch.presentationTier.RegulationDispatchAction.java

private String generateLinkForRemoval(HttpServletRequest request, RegulationDispatchWorkflowMetaProcess entry) {
    String contextPath = request.getContextPath();
    String realLink = contextPath
            + String.format("/createRegulationDispatch.do?dispatchId=%s&amp;method=prepareRemoveDispatch",
                    entry.getExternalId());
    realLink += String.format("&%s=%s", GenericChecksumRewriter.CHECKSUM_ATTRIBUTE_NAME,
            GenericChecksumRewriter.calculateChecksum(realLink, request.getSession()));

    return realLink;
}