List of usage examples for javax.servlet.http HttpServletRequest getContextPath
public String getContextPath();
From source file:org.jtwig.functions.SpringFunctions.java
@JtwigFunction(name = "path") public String path(HttpServletRequest request) { return new UrlPath().append(request.getContextPath()).toString(); }
From source file:eu.trentorise.smartcampus.resourceprovider.filter.ResourceFilter.java
public String getFullURL(HttpServletRequest request) { String cp = request.getContextPath(); if (cp == null || cp.isEmpty()) { return request.getRequestURI(); }//from w w w . j a v a2 s . c o m return request.getRequestURI().substring(cp.length()); }
From source file:com.hp.autonomy.hod.sso.HodTokenLogoutSuccessHandlerTest.java
@Test public void redirectsWithNoAuthentication() throws IOException, ServletException { final HttpServletRequest request = mock(HttpServletRequest.class); when(request.getContextPath()).thenReturn(CONTEXT_PATH); final String mockRedirectUrl = "/mock/redirect/url"; final HttpServletResponse response = mock(HttpServletResponse.class); final String expectedPath = CONTEXT_PATH + REDIRECT_PATH; when(response.encodeRedirectURL(expectedPath)).thenReturn(mockRedirectUrl); logoutSuccessHandler.onLogoutSuccess(request, response, null); verify(response).sendRedirect(mockRedirectUrl); }
From source file:psiprobe.controllers.apps.AjaxToggleContextController.java
@Override protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { if (!request.getContextPath().equals(contextName) && context != null) { try {/* ww w .j a va 2 s . co m*/ // Logging action Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); // get username logger if (context.getState().isAvailable()) { logger.info("{} requested STOP of {}", request.getRemoteAddr(), contextName); getContainerWrapper().getTomcatContainer().stop(contextName); logger.info(getMessageSourceAccessor().getMessage("probe.src.log.stop"), name, contextName); } else { logger.info("{} requested START of {}", request.getRemoteAddr(), contextName); getContainerWrapper().getTomcatContainer().start(contextName); logger.info(getMessageSourceAccessor().getMessage("probe.src.log.start"), name, contextName); } } catch (Exception e) { logger.error("Error during ajax request to START/STOP of '{}'", contextName, e); } } return new ModelAndView(getViewName(), "available", context != null && getContainerWrapper().getTomcatContainer().getAvailable(context)); }
From source file:ru.anr.base.facade.web.api.GlobalAPIExceptionHandler.java
/** * Processing a global exception/* w w w . j a v a 2 s . co m*/ * * @param rq * Original Http request * @param ex * An exception * @return String response * @throws Exception * If rethrown */ @ExceptionHandler(value = { Exception.class, RuntimeException.class }) @ResponseBody public String process(HttpServletRequest rq, Exception ex) throws Exception { logger.debug("API exception: {}", rq.getContextPath(), ex); if (AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class) != null) { throw ex; // Pre-defined exception handler exists } APICommand cmd = apis.error(ex); return cmd.getRawModel(); }
From source file:edu.usu.sdl.openstorefront.web.init.AngularRewriteRule.java
@Override public RewriteMatch matches(HttpServletRequest request, HttpServletResponse response) { String actionPath = request.getRequestURI().replace(request.getContextPath() + "/", ""); if (StringUtils.isNotBlank(actionPath)) { if (actionPath.contains("/") == false) { if (actionPath.contains(".") == false) { return new AngularRewriteMatch(); }/*from www . j a v a 2 s . c om*/ } } return null; }
From source file:br.com.semanticwot.cd.util.RedirectAfterLogout.java
@Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication a) throws IOException, ServletException { response.sendRedirect(request.getContextPath()); }
From source file:com.googlecode.psiprobe.controllers.apps.NoSelfContextHandlerController.java
protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { try {// w w w. j a v a 2s. c o 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(e); return new ModelAndView(new InternalResourceView(getViewName())); } return new ModelAndView(new RedirectView(request.getContextPath() + getViewName() + (isPassQueryString() ? "?" + request.getQueryString() : ""))); }
From source file:net.webpasswordsafe.server.controller.SsoController.java
private String getBaseUrl(HttpServletRequest request) { return request.getRequestURL().toString().replace(request.getRequestURI(), request.getContextPath()); }
From source file:org.tsm.concharto.web.changehistory.EventAdminController.java
private ModelAndView searchModelAndView(HttpServletRequest request) { return new ModelAndView(new RedirectView(request.getContextPath() + "/search/eventsearch.htm", true)); }