List of usage examples for javax.servlet.http HttpServletRequest getContextPath
public String getContextPath();
From source file:org.iti.agrimarket.view.UserController.java
@RequestMapping(value = { "/logout.htm" }) public String logout(HttpServletRequest request, Locale locale, HttpServletResponse response, Model model) { model.addAttribute("lang", locale); request.getSession().removeAttribute("user"); try {/*from w w w . j a v a2 s .c o m*/ response.sendRedirect(request.getContextPath() + "/index.htm"); } catch (IOException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } model.addAttribute("lang", locale); return "profile"; }
From source file:org.artifactory.util.HttpUtils.java
public static String getServletContextUrl(HttpServletRequest httpRequest) { String origUrl = httpRequest.getHeader(ArtifactoryRequest.ARTIFACTORY_OVERRIDE_BASE_URL); if (StringUtils.isNotBlank(origUrl)) { // original artifactory request url overrides request and base url return origUrl; }//from w ww . j av a 2s. co m CentralConfigService centralConfigService = ContextHelper.get().getCentralConfig(); String baseUrl = centralConfigService.getDescriptor().getUrlBase(); if (!StringUtils.isEmpty(baseUrl)) { String scheme = httpRequest.getScheme(); if (baseUrl.startsWith(scheme)) { return baseUrl; } else { int idx = baseUrl.indexOf("://"); if (idx > 0) { return scheme + "://" + baseUrl.substring(idx + 3); } else { return scheme + "://" + baseUrl; } } } return getServerUrl(httpRequest) + httpRequest.getContextPath(); }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.AbstractController.java
/** * Gets the url string./*from ww w .ja va2 s . c om*/ * * @param request the request * @return the url string */ private String getUrlString(HttpServletRequest request) { return request.getContextPath(); }
From source file:com.frameworkx.AbstractApplication.java
/** * Iterate through the routing table and find a matching entry. If a matching route is not found, * a 404 is generated//from ww w .ja va 2 s . co m * * @param request * @param response */ public void execute(final HttpServletRequest request, final HttpServletResponse response) { final String path = request.getRequestURI().substring(request.getContextPath().length()); // plugin requestReceived hook for (Plugin p : this.plugins) { p.onRequestReceived(request, response); } try { for (Map.Entry<Pattern, RouteHandler> kvp : this.routes.entrySet()) { Matcher m = kvp.getKey().matcher(path); if (m.matches()) { kvp.getValue().execute(request, response, m); return; } } // @todo 404 } catch (Exception ex) { for (Plugin p : this.plugins) { p.onUncaughtException(request, response); } // @todo 500 throw new RuntimeException(ex); } finally { for (Plugin p : this.plugins) { p.onRequestFinally(request, response); } } }
From source file:edu.harvard.hul.ois.pds.ws.PDSWebService.java
public static void printError(HttpServletRequest req, HttpServletResponse res, String message, Throwable e) { HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(req); wrapper.setAttribute("message", message); wrapper.setAttribute("pdsUrl", req.getContextPath()); wrapper.setAttribute("exception", e); wrapper.setAttribute("req", req); RequestDispatcher rd = req.getRequestDispatcher("/api-error.jsp?"); try {/* ww w . jav a 2s. c o m*/ rd.forward(req, res); } catch (Exception e1) { e1.printStackTrace(); } }
From source file:br.vschettino.forum.controller.SiteController.java
@RequestMapping(value = "/login", method = RequestMethod.POST) @ResponseBody//from www . j a va2 s . c o m public ModelAndView login(HttpServletRequest request, HttpServletResponse response, @RequestParam("usuario") String usuario, @RequestParam("senha") String senha) { Usuario visitante = usuarioDAO.authenticateUsuario(usuario, senha); try { if (visitante == null) { response.sendRedirect(request.getContextPath() + "/web/login?error=true"); return null; } request.getSession().setAttribute("usuario", visitante); response.sendRedirect(request.getContextPath() + "/web/site/"); } catch (IOException ex) { Logger.getLogger(SiteController.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:com.justcloud.osgifier.servlet.OsgifierServlet.java
public String buildUrl(HttpServletRequest req) { return req.getRequestURI().replace(req.getContextPath(), "").replace(req.getServletPath(), ""); }
From source file:es.logongas.ix3.web.security.AuthorizationInterceptorImplURL.java
public void checkAuthorized(Principal principal, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, DataSession dataSession) throws BusinessSecurityException { String secureResourceTypeName = SECURE_RESOURCE_TYPE_NAME; String secureResource = getSecureURI(httpServletRequest.getRequestURI(), httpServletRequest.getContextPath()); String permissionName = httpServletRequest.getMethod(); Object arguments = getArguments(httpServletRequest.getParameterMap()); boolean isAuthorized = authorizationManager.authorized(principal, secureResourceTypeName, secureResource, permissionName, arguments, dataSession); if (isAuthorized == false) { throw new BusinessSecurityException( "El usuario " + principal + " no tiene acceso a la URL:" + secureResource); }/*w w w . j a v a2 s . c o m*/ }
From source file:pivotal.au.se.gemfirexdweb.controller.AddLoaderController.java
@RequestMapping(value = "/addloader", method = RequestMethod.GET) public String createLoader(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 ww .j a va 2 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 add new Table Loader"); AddLoader loaderAttribute = new AddLoader(); if (request.getParameter("tableName") != null) { loaderAttribute.setTableName(request.getParameter("tableName")); } if (request.getParameter("schemaName") != null) { loaderAttribute.setSchemaName(request.getParameter("schemaName")); } model.addAttribute("loaderAttribute", loaderAttribute); // This will resolve to /WEB-INF/jsp/addloader.jsp return "addloader"; }