List of usage examples for javax.servlet.http HttpServletRequest getContextPath
public String getContextPath();
From source file:com.netspective.sparx.value.source.PageIdValueSource.java
/** * Gets the navigation page's URL as a Value object. If the navigation tree or the page itself * was not found, a GenericValue object with the error message is returned. */// www . ja v a2 s .c o m public Value getValue(ValueContext vc) { NavigationTree navTree = null; HttpServletValueContext svc = (HttpServletValueContext) (vc instanceof ConnectionContext ? ((ConnectionContext) vc).getDatabaseValueContext() : vc); HttpServletRequest request = svc.getHttpRequest(); String contextPath = request.getContextPath(); String servletPath = request.getServletPath(); if (treeSource == null || treeSource.length() == 0) { final NavigationContext navigationContext = svc.getNavigationContext(); if (navigationContext != null) navTree = navigationContext.getActivePage().getOwner(); else { AuthenticatedUser user = svc.getAuthenticatedUser(); if (user instanceof NavigationControllerAuthenticatedUser) navTree = ((NavigationControllerAuthenticatedUser) user).getUserSpecificNavigationTree( (NavigationControllerServlet) svc.getHttpServlet(), svc.getHttpRequest(), svc.getHttpResponse()); else navTree = svc.getProject().getDefaultNavigationTree(); } if (navTree == null) return new GenericValue("No default NavigationTree found"); } else { navTree = navTree = svc.getProject().getNavigationTree(treeSource); if (navTree == null) return new GenericValue("No navigation tree named '" + treeSource + "' was found"); } if (!pageId.startsWith("/")) { // relative page ID NavigationPage activePage = svc.getNavigationContext().getActivePage(); if (activePage != null) pageId = activePage.getQualifiedName() + "/" + pageId; else { log.error("Active page was not found for relative page ID '" + pageId + "'."); return new GenericValue("Active page was not found for relative page ID '" + pageId + "'."); } } // find a matching path with respect to the nav id NavigationTree.FindResults pathResults = navTree.findPath(pageId); NavigationPath path = pathResults.getMatchedPath(); if (path == null) { // a matching path was not found log.error("Navigation page ID '" + pageId + "' was not found."); return new GenericValue("Navigation page ID '" + pageId + "' was not found."); } else { String localParams = null; if (reqParams != null) { // process the request parameters localParams = reqParams.getValue(vc).getTextValue(); } return new GenericValue(contextPath + servletPath + path.getQualifiedName() + (localParams != null ? "?" + localParams : "")); } }
From source file:com.consol.citrus.simulator.servlet.StaticResourceServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Template template = compileHandlebarsTemplate(getTemplateName(req.getRequestURI())); Map<String, Object> model = new HashMap<String, Object>(); model.put("contextPath", req.getContextPath()); template.apply(Context.newContext(model), resp.getWriter()); }
From source file:psiprobe.controllers.connectors.ResetConnectorStatsController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { String connectorName = ServletRequestUtils.getRequiredStringParameter(request, "cn"); collectorBean.reset(connectorName);//from w w w. j av a2 s . c om return new ModelAndView(new RedirectView(request.getContextPath() + getViewName())); }
From source file:jp.co.opentone.bsol.linkbinder.view.filter.AbstractFilter.java
/** * ??.//w w w. jav a 2s.c om * @param request * @param response ? * @param page * @throws IOException */ protected void redirectTo(HttpServletRequest request, HttpServletResponse response, String page) throws IOException { response.sendRedirect(String.format("%s%s", request.getContextPath(), page)); }
From source file:fr.xebia.cocktail.CocktailRssView.java
@Override protected void buildFeedMetadata(Map<String, Object> model, Channel feed, HttpServletRequest request) { feed.setTitle("Cocktail App"); feed.setDescription("Java Tutorials and Examples"); feed.setLink(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath()); super.buildFeedMetadata(model, feed, request); }
From source file:org.openmrs.module.jsslab.web.controller.JssLabAdminSetupController.java
@RequestMapping(value = "/finishSetup", method = RequestMethod.GET) @ResponseBody/*from www . jav a2s .c om*/ public String finishSetup(HttpServletRequest request) { markSetupCompleted(); // String resultView = "forward:" + request.getContextPath() + "/" + targetView + ".htm"; // return resultView; return request.getContextPath() + "/" + targetView + ".htm"; }
From source file:pivotal.au.se.gemfirexdweb.controller.RefreshController.java
@RequestMapping(value = "/refresh", method = RequestMethod.GET) public String showTables(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 {//from w w w. ja v a 2 s .c o 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 refresh schema object list"); Map schemaMap = (Map) session.getAttribute("schemaMap"); Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); // get schema count now schemaMap = QueryUtil.populateSchemaMap(conn, schemaMap, (String) session.getAttribute("schema")); session.setAttribute("schemaMap", schemaMap); // This will resolve to /WEB-INF/jsp/tables.jsp return "main"; }
From source file:net.riezebos.thoth.servlets.ServletBase.java
protected String getContextUrl(HttpServletRequest request) { return request.getContextPath() + "/" + getContext(request); }
From source file:com.googlecode.psiprobe.controllers.apps.RemoveApplicationAttributeController.java
protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { String attrName = ServletRequestUtils.getStringParameter(request, "attr"); context.getServletContext().removeAttribute(attrName); return new ModelAndView( new RedirectView(request.getContextPath() + getViewName() + "?" + request.getQueryString())); }
From source file:com.education.lessons.ui.server.login.OpenIDLoginController.java
/** * Builds the callback URL; realm + context path + return path, e.g. * http://www.mydomain.com/context/return.htm *//*w w w.ja v a2 s . c o m*/ private String getReturnTo(HttpServletRequest request) { String realm = getRealm(request); realm = realm.substring(0, realm.length() - 1); String contextPath = request.getContextPath(); String servletPath = request.getServletPath(); return realm + contextPath + servletPath + "/login/openid/verify"; }