List of usage examples for javax.servlet.http HttpServletRequest getContextPath
public String getContextPath();
From source file:org.chos.transaction.passport.SessionInterceptor.java
/** * (Javadoc)//from w w w .j a v a2 s . com * * @see org.springframework.web.servlet.HandlerInterceptor#preHandle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object) */ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception { String requestUrl = request.getRequestURI().replace(request.getContextPath(), ""); System.out.println(requestUrl); if (null != allowUrls && allowUrls.length >= 1) { for (String url : allowUrls) { if (requestUrl.contains(url)) { return true; } } } Session session = httpContextSessionManager.getSession(request); if (session != null) { return true; //true???postHandle(), afterCompletion() } throw new SessionException(); }
From source file:org.sakaiproject.imagegallery.web.MultiFileUploaderController.java
public ModelAndView singleFileUpload(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) { return new ModelAndView(new RedirectView( "/site/AddInformationToImages?imageIds=" + storeNewImage((MultipartHttpServletRequest) request), true));/* w w w . j av a 2 s. com*/ } return null; }
From source file:org.simbasecurity.core.service.http.ChangePasswordController.java
private String reconstructSimbaWebURL(HttpServletRequest request) { return request.getScheme() + "://" + request.getServerName() + (request.getServerPort() != 80 ? ":" + request.getServerPort() : "") + request.getContextPath(); }
From source file:com.glaf.shiro.filter.GlobalPermissionsAuthorizationFilter.java
@Override public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException { HttpServletRequest req = (HttpServletRequest) request; Subject subject = getSubject(request, response); String uri = req.getRequestURI(); String contextPath = req.getContextPath(); int i = uri.indexOf(contextPath); if (i > -1) { uri = uri.substring(i + contextPath.length()); }//from ww w . ja va 2 s .c om if (StringUtils.isBlank(uri)) { uri = "/"; } boolean permitted = false; if ("/".equals(uri)) { permitted = true; } else { permitted = subject.isPermitted(uri); } return permitted; }
From source file:com.acc.storefront.security.cookie.EnhancedCookieGenerator.java
/** * Sets dynamically the {@link Cookie#setPath(String)} value using available * {@link HttpServletRequest#getContextPath()}. *//*from ww w .java2 s .c om*/ protected void setEnhancedCookiePath(final Cookie cookie) { if (!canUseDefaultPath()) { final HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder .currentRequestAttributes()).getRequest(); cookie.setPath(request.getContextPath()); } }
From source file:de.berlios.jhelpdesk.web.preferences.LookAndFeelEditController.java
private Cookie createCookie(HttpServletRequest req, Locale loc) { Cookie cookie = new Cookie("jhd_locale", loc.getLanguage()); cookie.setMaxAge(SECONDS_BY_WEEK);/*from ww w. ja v a 2 s . c o m*/ cookie.setPath(req.getContextPath()); return cookie; }
From source file:de.uni_koeln.spinfo.maalr.webapp.i18n.InternationalUrlFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { //long start = System.nanoTime(); HttpServletRequest h = (HttpServletRequest) request; String uri = h.getRequestURI(); String path = h.getContextPath(); Locale userLocale = request.getLocale(); h.getSession().setAttribute("lang", userLocale.getLanguage()); String url = uri.substring(path.length()); /*/*from ww w .j ava 2 s . c o m*/ * Idee: die URL in ihre Bestandteile zerlegen und die einzelnen Teile * in einem Keyword-Tree matchen. Auf jeder Stufe wird dabei die eigentliche * URL um ein neues Element ergnzt. * * Funktioniert auf diese Weise gut fr statische URLs, aufbau eines Baums * fr URLs mit fest definierten Klassen (z.B. bersetzungsrichtung) ist ebenfalls mglich. * * Funktioniert aber nicht fr dynamische Bestandteile - da muss eine Wildcard * rein. * * :wrterbuch:deutsch-rumantsch:nase.html oder .json oder .xml * * Baum: * wrterbuch -> dictionary * deutsch-rumantsch -> tudesg->rumantsch * * -> * * ending * * Filter-Funktionalitt: * * a) Prfen, ob die URL schon in die Zielsprache bersetzt wurde. Falls ja: * doFilter() aufrufen, sonst bersetzen (andernfalls Endlos-Schleife). * * b) die gewhlte Sprache irgendwo in der Session hinterlegen, damit der * Rest des Programms (GUI) entsprechend der URL auch die richtigen Elemente * darstellt. * * c) Hilfsklasse notwendig, die URLs entsprechend der Sprache generiert, * z.B. fr dictionary (s.o.), aber auch fr "translate", einschlielich der * Durchblttern-Funktion. HTTP-GET sollte auch bersetzt werden (also Parameter-Namen), * POST nicht. * * d) Die Generierung des Baums darf lange dauern, die Abfrage muss aber * schnell sein - also z.B. Pattern.compile() beim Aufbau des Baums, nicht * beim Abfragen. * */ if ("/hilfe.html".equals(url) || "/help.html".equals(url)) { // change url and forward RequestDispatcher dispatcher = request.getRequestDispatcher("/agid.html"); // long end = System.nanoTime(); dispatcher.forward(request, response); } else { // long end = System.nanoTime(); chain.doFilter(request, response); } }
From source file:com.controller.SkillController.java
@RequestMapping(value = "admin/skill_add/save", method = RequestMethod.POST) public View saveSkill(HttpServletRequest request, @ModelAttribute Skill skill) { skill.setStatus(1);//from ww w . ja va2s. c o m ski.addSkill(skill); return new RedirectView(request.getContextPath() + "/admin/skill_list"); }
From source file:edu.emory.cci.aiw.cvrg.eureka.servlet.filter.UserFilter.java
private void goHome(HttpServletRequest inRequest, HttpServletResponse inResponse) throws IOException { inResponse.sendRedirect(inRequest.getContextPath() + "/logout?goHome=true"); }
From source file:org.chos.transaction.passport.LoginInterceptor.java
/** * (Javadoc)/*from www. jav a 2 s . com*/ * * @see org.springframework.web.servlet.HandlerInterceptor#preHandle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object) */ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception { String requestUrl = request.getRequestURI().replace(request.getContextPath(), ""); System.out.println(requestUrl); Session session = httpContextSessionManager.getSession(request); if (session != null) { String redirect = request.getParameter("redirect"); if (StringUtils.isBlank(redirect)) { redirect = redirectUrl; } response.sendRedirect(redirect); } return true; }