List of usage examples for javax.servlet.http HttpServletRequest getContextPath
public String getContextPath();
From source file:se.trillian.goodies.stripes.ViewForwardResolution.java
protected String extractViewName(String uri, HttpServletRequest request) { String contextPath = request.getContextPath(); uri = StringUtils.removeStart(uri, contextPath); return uri.replaceFirst(viewNameSuffixPattern, ""); }
From source file:org.bpmscript.web.LogoutController.java
/** * Invalidate the session and redirect the browser to contextPath/index.html *///from w w w. j a v a2s. c o m @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { request.getSession(true).invalidate(); return new ModelAndView(new RedirectView(request.getContextPath() + "/index.html")); }
From source file:org.uaa.security.core.LoginHandler.java
public boolean isLogin(HttpServletRequest request) { String uri = request.getRequestURI(); log.debug("context: " + request.getContextPath()); log.debug("uri: " + request.getRequestURI()); int pathParamIndex = uri.indexOf(';'); if (pathParamIndex > 0) { // strip everything from the first semi-colon uri = uri.substring(0, pathParamIndex); }/*from w ww .ja v a 2s . com*/ int queryParamIndex = uri.indexOf('?'); if (queryParamIndex > 0) { // strip everything from the first question mark uri = uri.substring(0, queryParamIndex); } if ("".equals(request.getContextPath())) { return uri.endsWith(login_url); } return uri.endsWith(request.getContextPath() + login_url); }
From source file:psiprobe.controllers.deploy.UndeployContextController.java
@Override protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { try {/*from www . j av a2s . co m*/ if (request.getContextPath().equals(contextName)) { throw new IllegalStateException( getMessageSourceAccessor().getMessage("probe.src.contextAction.cannotActOnSelf")); } getContainerWrapper().getTomcatContainer().remove(contextName); // Logging action Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); // get username logger logger.info(getMessageSourceAccessor().getMessage("probe.src.log.undeploy"), name, contextName); } catch (Exception e) { request.setAttribute("errorMessage", e.getMessage()); logger.error("Error during undeploy of '{}'", contextName, e); return new ModelAndView( new InternalResourceView(getFailureViewName() == null ? getViewName() : getFailureViewName())); } return new ModelAndView(new RedirectView(request.getContextPath() + getViewName())); }
From source file:org.openmrs.module.rwandaprimarycare.LoginController.java
/** * Convenience method for pulling the correct page to redirect * to out of the request. IN case of touchscreeen module, we are not interested in * anything else but home page. Leaving method in place just in case it will change in * future.//w w w . jav a2 s.c o m * * @param request the current request * @return the page to redirect to as determined by parameters in the request */ private String determineRedirect(HttpServletRequest request) { String redirect = request.getContextPath() + "/module/rwandaprimarycare/chooseLocation.form"; log.debug("Going to use redirect: '" + redirect + "'"); return redirect; }
From source file:it.eng.spagobi.commons.utilities.urls.WebUrlBuilder.java
/** * Inits the.//w w w. j a va 2 s . co m * * @param aHttpServletRequest the a http servlet request */ public void init(HttpServletRequest aHttpServletRequest) { logger.debug("IN"); baseResourceURL = aHttpServletRequest.getContextPath() + "/"; baseURL = aHttpServletRequest.getContextPath() + "/servlet/AdapterHTTP"; logger.debug("OUT.baseURL=" + baseURL); }
From source file:org.openmrs.module.bom.web.controller.LoginPageOverrideController.java
/** * Convenience method for pulling the correct page to redirect * to out of the request. IN case of touchscreeen module, we are not interested in * anything else but home page. Leaving method in place just in case it will change in * future.//from w w w.j av a2 s . c o m * * @param request the current request * @return the page to redirect to as determined by parameters in the request */ private String determineRedirect(HttpServletRequest request) { String redirect = request.getContextPath() + "/module/bom/bomHome.htm"; log.debug("Going to use redirect: '" + redirect + "'"); return redirect; }
From source file:com.hp.autonomy.hod.sso.SsoAuthenticationEntryPoint.java
/** * Redirects the sender of a request which has failed authentication to the SSO page *///from w ww . jav a2s .c om @Override public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { response.sendRedirect(request.getContextPath() + ssoEntryPage); }
From source file:org.sakaiproject.imagegallery.integration.standalone.ImageStreamingController.java
/** * @see org.springframework.web.servlet.mvc.AbstractController#handleRequestInternal(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */// w ww.j av a2 s.c o m @Override protected ModelAndView handleRequestInternal(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()); String fileId = request.getPathInfo().substring(1); ImageFile imageFile = fileLibraryService.getImageFile(fileId); response.setContentType(imageFile.getContentType()); FileStreamer fileStreamer = (FileStreamer) fileLibraryService; fileStreamer.streamImage(fileId, response.getOutputStream()); return null; }
From source file:org.openmrs.module.patientnarratives.web.controller.HtmlFormEntryRequestController.java
@RequestMapping(FORM_PATH) public ModelAndView handleRequest(HttpServletRequest request) { returnUrl = request.getContextPath() + "/module/patientnarratives/patientNarrativesForm.form"; HtmlFormEntryPortletController htmlFormEntryPortletController; FormEntrySession session = null;// w ww. j a v a 2 s . c o m try { htmlFormEntryPortletController = new HtmlFormEntryPortletController(); session = htmlFormEntryPortletController.getFormEntrySession(request); List<FormSubmissionError> validationErrors = session.getSubmissionController() .validateSubmission(session.getContext(), request); if (validationErrors != null && validationErrors.size() > 0) { //errors.reject("Fix errors"); } } catch (Exception ex) { log.error("Exception during form validation", ex); //errors.reject("Exception during form validation, see log for more details: " + ex); } // if (errors.hasErrors()) { // return new ModelAndView(FORM_PATH, "command", session); // } // no form validation errors, proceed with submission try { session.prepareForSubmit(); if (session.getContext().getMode() == FormEntryContext.Mode.ENTER && session.hasPatientTag() && session.getPatient() == null && (session.getSubmissionActions().getPersonsToCreate() == null || session.getSubmissionActions().getPersonsToCreate().size() == 0)) throw new IllegalArgumentException("This form is not going to create an Patient"); if (session.getContext().getMode() == FormEntryContext.Mode.ENTER && session.hasEncouterTag() && (session.getSubmissionActions().getEncountersToCreate() == null || session.getSubmissionActions().getEncountersToCreate().size() == 0)) throw new IllegalArgumentException("This form is not going to create an encounter"); session.getSubmissionController().handleFormSubmission(session, request); HtmlFormEntryUtil.getService().applyActions(session); String successView = session.getReturnUrlWithParameters(); request.getSession().setAttribute(WebConstants.OPENMRS_MSG_ATTR, "patientnarratives.module.narrative.save.success"); if (successView == null) successView = request.getContextPath() + "/module/patientnarratives/patientNarrativesForm.form"; if (StringUtils.hasText(request.getParameter("closeAfterSubmission"))) { return new ModelAndView(new RedirectView(returnUrl)); // return new ModelAndView(closeDialogView, "dialogToClose", request.getParameter("closeAfterSubmission")); } else { return new ModelAndView(new RedirectView(returnUrl)); // return new ModelAndView(new RedirectView(successView)); } } catch (ValidationException ex) { log.error("Invalid input:", ex); // errors.reject(ex.getMessage()); } catch (BadFormDesignException ex) { log.error("Bad Form Design:", ex); // errors.reject(ex.getMessage()); } catch (Exception ex) { log.error("Exception trying to submit form", ex); StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); // errors.reject("Exception! " + ex.getMessage() + "<br/>" + sw.toString()); } // if ((alert != null) && (alert == true)) { // } // if we get here it's because we caught an error trying to submit/apply // return new ModelAndView(returnUrl, "command", session); return new ModelAndView(new RedirectView(returnUrl)); }