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:org.slc.sli.dashboard.web.controller.GenericLayoutController.java

protected void addCommonData(ModelMap model, HttpServletRequest request) {
    addHeaderFooter(model);//from  w w w .  j  a  va  2 s .c  om
    model.addAttribute(GOOGLE_ANALYTICS_TRACKER_CONSTANT, googleAnalyticsTrackerId);
    model.addAttribute(Constants.CONTEXT_ROOT_PATH, request.getContextPath());
    model.addAttribute(Constants.CONTEXT_PREVIOUS_PATH, "javascript:history.go(-1)");
    model.addAttribute(MINIFY_JS_CONSTANT, minifyJs);
}

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

@RequestMapping(value = "/viewconmap", method = RequestMethod.GET)
public String worksheet(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 {/*  www .j a  v  a2  s. co m*/
        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 show connection map");

    ConnectionManager cm = ConnectionManager.getInstance();

    String conMapAction = request.getParameter("conMapAction");
    String key = request.getParameter("key");

    logger.debug("conMapAction = " + conMapAction);
    logger.debug("key = " + key);

    if (conMapAction != null) {
        if (conMapAction.equalsIgnoreCase("DELETE")) {
            // remove this connection from Map and close it.
            cm.removeConnection(key);
            logger.debug("Connection closed for key " + key);
            model.addAttribute("saved", "Successfully closed connection with key " + key);
        }
    }

    model.addAttribute("conmap", cm.getConnectionMap());
    model.addAttribute("conmapsize", cm.getConnectionListSize());

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

From source file:iddb.web.security.service.UserServiceFilter.java

/**
 * @param s//from   ww  w .  j a v a  2s. c o  m
 * @param request
 * @return
 * @throws IOException 
 */
private boolean haveAccess(Subject s, HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String path = req.getRequestURI();
    log.debug("Check path {}", path);
    if (!req.getContextPath().isEmpty()) {
        path = StringUtils.removeStartIgnoreCase(path, req.getContextPath());
    }
    if (!path.startsWith("/")) {
        path = "/" + path;
    } else if (path.startsWith("//")) {
        path = path.substring(1);
    }
    for (String p : urls.keySet()) {
        if (p.endsWith("**")) {
            if (path.startsWith(p.substring(0, p.length() - 2))) {
                return checkRoles(s, req, resp, p);
            }
        } else {
            if (path.equalsIgnoreCase(p)) {
                return checkRoles(s, req, resp, p);
            }
        }
    }
    return true;
}

From source file:be.fedict.eid.idp.protocol.saml2.AbstractSAML2MetadataHttpServlet.java

private String getLocation(HttpServletRequest request) {

    String location = "https://" + request.getServerName();
    if (request.getServerPort() != 443) {
        location += ":" + request.getServerPort();
    }//  w w  w .jav  a2 s.  co m
    location += request.getContextPath() + IdentityProviderProtocolService.PROTOCOL_ENDPOINT_PATH + "/"
            + getPath();
    LOG.debug("location: " + location);
    return location;
}

From source file:de.iai.ilcd.webgui.controller.ConfigurationBean.java

/**
 * Use this constructor if not in the context of JSF; i.e. initialize context path by yourself
 * /*from   ww w . java 2  s.  co  m*/
 * @param request
 *            the request to get the environment from
 */
public ConfigurationBean(HttpServletRequest request) {
    this(request.getContextPath());
}

From source file:fll.web.ajax.DisplayQueryServlet.java

/**
 * Convert displayPage variable into URL. The names here need to match the
 * values//w  w  w . ja  v  a2 s.c  o m
 * of the "remotePage" radio buttons in remoteControl.jsp.
 */
private String pickURL(final HttpServletRequest request, final String displayPage, final String displayURL,
        final ServletContext application, final HttpSession session) {
    final String contextPath = request.getContextPath();

    if (null == displayPage) {
        return contextPath + "/welcome.jsp";
    } else if ("scoreboard".equals(displayPage)) {
        return contextPath + "/scoreboard/main.jsp";
    } else if ("slideshow".equals(displayPage)) {
        return contextPath + "/slideshow/index.jsp";
    } else if ("playoffs".equals(displayPage)) {
        return contextPath + "/playoff/remoteMain.jsp";
    } else if ("finalistSchedule".equals(displayPage)) {
        try {
            String finalistScheduleDivision = null;

            final String displayName = SessionAttributes.getAttribute(session, "displayName", String.class);
            if (null != displayName) {
                finalistScheduleDivision = ApplicationAttributes.getAttribute(application,
                        displayName + "_finalistScheduleDivision", String.class);
            }

            if (null == finalistScheduleDivision) {
                finalistScheduleDivision = ApplicationAttributes.getAttribute(application, "finalistDivision",
                        String.class);
            }

            return String.format(
                    "%s/report/finalist/PublicFinalistDisplaySchedule.jsp?finalistScheduleScroll=true&division=%s",
                    contextPath, URLEncoder.encode(finalistScheduleDivision, Utilities.DEFAULT_CHARSET.name()));
        } catch (final UnsupportedEncodingException e) {
            throw new FLLInternalException("Cannot encode using default charset?", e);
        }
    } else if ("special".equals(displayPage)) {
        return contextPath + "/" + displayURL;
    } else {
        return contextPath + "/welcome.jsp";
    }
}

From source file:com.acc.storefront.filters.AcceleratorAddOnFilter.java

protected String getFullPathNameFromRequest(final HttpServletRequest request) {
    final String ctxPath = request.getContextPath();
    String requestUri = request.getRequestURI();

    if (requestUri.startsWith(ctxPath)) {
        requestUri = requestUri.substring(ctxPath.length());
    }/*  w ww .j a  v  a  2s . c o  m*/

    return FilenameUtils.normalize(request.getSession().getServletContext().getRealPath(requestUri), true);
}

From source file:io.lavagna.web.security.CSFRFilter.java

/**
 * Return true if the filter must check the request
 *
 * @param request/*from  w w  w  .ja va 2 s  .c  om*/
 * @return
 */
private boolean mustCheckCSRF(HttpServletRequest request) {

    // ignore the websocket fallback...
    if ("POST".equals(request.getMethod()) && WEBSOCKET_FALLBACK
            .matcher(StringUtils.removeStart(request.getRequestURI(), request.getContextPath())).matches()) {
        return false;
    }

    return !CSRF_METHOD_DONT_CHECK.matcher(request.getMethod()).matches();
}