List of usage examples for javax.servlet.http HttpServletRequest getContextPath
public String getContextPath();
From source file:psiprobe.controllers.apps.NoSelfContextHandlerController.java
@Override protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { try {// w ww . j a va 2 s . co m if (request.getContextPath().equals(contextName)) { throw new IllegalStateException( getMessageSourceAccessor().getMessage("probe.src.contextAction.cannotActOnSelf")); } executeAction(contextName); } catch (Exception e) { request.setAttribute("errorMessage", e.getMessage()); logger.error("Error during invocation", e); return new ModelAndView(new InternalResourceView(getViewName())); } return new ModelAndView(new RedirectView(request.getContextPath() + getViewName() + (isPassQueryString() ? "?" + request.getQueryString() : ""))); }
From source file:com.inkubator.securitycore.util.AuthenticationSuccessHandler.java
@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { LOGGER.info("Success Login"); response.sendRedirect(request.getContextPath() + "/protected/home.htm"); }
From source file:org.sarons.spring4me.web.servlet.DispatcherServlet.java
private void exportContextPath(HttpServletRequest request, ModelAndView mv) { mv.addObject(Keys.REQUEST_KEY_BASE, request.getContextPath()); request.setAttribute(Keys.REQUEST_KEY_BASE, request.getContextPath()); }
From source file:com.roche.iceboar.demo.JnlpServlet.java
/** * This method handle all HTTP requests for *.jnlp files (defined in web.xml). Method check, is name correct * (allowed), read file from disk, replace #{codebase} (it's necessary to be generated based on where application * is deployed), #{host} () and write to the response. * <p>/*from ww w . j ava 2s . c o m*/ * You can use this class in your code for downloading JNLP files. * Return a content of requested jnlp file in response. * * @throws IOException when can't close some stream */ @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { String contextPath = request.getContextPath(); String requestURI = request.getRequestURI(); String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); String codebase = host + contextPath; String filename = StringUtils.removeStart(requestURI, contextPath); response.setContentType("application/x-java-jnlp-file"); response.addHeader("Pragma", "no-cache"); response.addHeader("Expires", "-1"); OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream()); InputStream in = JnlpServlet.class.getResourceAsStream(filename); if (in == null) { error(response, "Can't open: " + filename); return; } BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line = reader.readLine(); while (line != null) { line = line.replace("#{codebase}", codebase); line = line.replace("#{host}", host); out.write(line); out.write("\n"); line = reader.readLine(); } out.flush(); out.close(); reader.close(); }
From source file:com.thoughtworks.go.server.controller.PipelineStatusController.java
String getFullContextPath(HttpServletRequest request) throws URIException { String contextPath = request.getContextPath(); StringBuffer url = request.getRequestURL(); URI uri = new URI(url.toString()); uri.setPath(contextPath);/*w w w .ja v a2s . com*/ return uri.toString(); }
From source file:grails.plugin.springsecurity.web.GrailsRedirectStrategy.java
protected String calculateRedirectUrl(HttpServletRequest request, String url) { if (UrlUtils.isAbsoluteUrl(url)) { return url; }/* w w w.j a v a 2s . com*/ url = request.getContextPath() + url; if (!useHeaderCheckChannelSecurity) { return url; } return UrlUtils.buildFullRequestUrl(request.getScheme(), request.getServerName(), portResolver.getServerPort(request), url, null); }
From source file:de.iew.web.view.js.JavascriptConfigView.java
protected String renderBaseUrlHelper(HttpServletRequest request) { StringBuffer sb = new StringBuffer("baseUrl: function(/* String|NULL */ url) {"); sb.append("var baseUrl = '").append(request.getContextPath()).append("';") .append("return baseUrl + (url ? url : '');}"); return sb.toString(); }
From source file:com.doculibre.constellio.filters.LocalRequestFilter.java
private boolean isIgnoredRequest(ServletRequest request) { boolean ignoredRequest = false; HttpServletRequest httpRequest = (HttpServletRequest) request; String contextPath = httpRequest.getContextPath(); String requestURI = httpRequest.getRequestURI(); String contextRelativePath = requestURI.substring(contextPath.length()); for (String ignoredPrefix : ignoredPrefixes) { ignoredRequest = contextRelativePath.startsWith(ignoredPrefix); if (ignoredRequest) { break; }/*w ww . j a v a2s . c o m*/ } return ignoredRequest; }
From source file:com.companyname.services.OnLogoutHandler.java
public String getCookiePath(HttpServletRequest request) { if (cookiePath == null) { String contextPath = request.getContextPath(); return contextPath.length() > 0 ? contextPath : "/"; } else {/*w w w . j ava 2 s . c o m*/ return cookiePath; } }
From source file:csns.web.filter.RegistrationFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String contextPath = request.getContextPath(); String path = request.getRequestURI().substring(contextPath.length()); if (SecurityUtils.isAuthenticated() && SecurityUtils.getUser().isTemporary() && !isPassThrough(path)) { response.sendRedirect(contextPath + "/register"); return;/*from w w w . j ava 2 s.c o m*/ } filterChain.doFilter(request, response); }