List of usage examples for javax.servlet.http HttpServletResponse encodeRedirectUrl
@Deprecated
public String encodeRedirectUrl(String url);
From source file:org.etudes.ambrosia.util.AmbrosiaServlet.java
/** * Send a redirect to the error destination. * /*from ww w . j a v a 2 s. c om*/ * @param req * @param res * @throws IOException */ protected void redirectError(HttpServletRequest req, HttpServletResponse res) throws IOException { String error = Web.returnUrl(req, "/" + this.errorView); res.sendRedirect(res.encodeRedirectURL(error)); }
From source file:org.apache.geronimo.daytrader.javaee6.web.TradeAppServlet.java
private void sendRedirect(HttpServletResponse resp, String page) throws ServletException, IOException { resp.sendRedirect(resp.encodeRedirectURL(page)); }
From source file:org.etudes.mneme.tool.AssessmentImportView.java
/** * {@inheritDoc}/* w w w.j av a 2 s.c om*/ */ public void get(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // security if (!this.assessmentService.allowManageAssessments(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } String returnUrl = ""; String returnSort = "0A"; if (params.length == 4) { returnUrl = params[2]; returnSort = params[3]; } context.put("returnUrl", returnUrl); context.put("returnSort", returnSort); // render uiService.render(ui, context); }
From source file:de.appsolve.padelcampus.filter.AdminFilter.java
/** * @param request/* w w w . ja va 2 s . c o m*/ * @param response * @param chain * @throws java.io.IOException * @throws javax.servlet.ServletException * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) */ @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; Player player = sessionUtil.getUser(httpRequest); if (player == null) { sessionUtil.setLoginRedirectPath(httpRequest, httpRequest.getRequestURI()); httpResponse.sendRedirect(httpResponse.encodeRedirectURL("/login")); return; } Set<Privilege> privileges = sessionUtil.getPrivileges(httpRequest); String pathInfo = httpRequest.getRequestURI().substring(httpRequest.getContextPath().length()); for (Privilege privilege : privileges) { if (privilege.getPathPattern().matcher(pathInfo).matches()) { chain.doFilter(request, response); if (!StringUtils.isEmpty(httpRequest.getMethod()) && httpRequest.getMethod().equalsIgnoreCase("POST")) { LOG.info(String.format("AUDIT: %s executed %s %s", player, httpRequest.getMethod(), httpRequest.getRequestURI())); Enumeration<String> parameterNames = request.getParameterNames(); while (parameterNames.hasMoreElements()) { String paramName = parameterNames.nextElement(); String paramValue = request.getParameter(paramName); LOG.info(String.format("%s: %s", paramName, paramValue)); } } return; } } httpResponse.sendError(HttpStatus.SC_FORBIDDEN); } else { chain.doFilter(request, response); } }
From source file:com.lti.system.MyLogoutFilter.java
/** * Allow subclasses to modify the redirection message. * * @param request the request//w w w .j a v a 2s . c o m * @param response the response * @param url the URL to redirect to * * @throws IOException in the event of any failure */ protected void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url) throws IOException { if (!url.startsWith("http://") && !url.startsWith("https://")) { url = request.getContextPath() + url; } response.sendRedirect(response.encodeRedirectURL(url)); }
From source file:org.apache.struts.chain.commands.servlet.PerformForward.java
private void handleAsRedirect(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException { if (uri.startsWith("/")) { uri = request.getContextPath() + uri; }//from ww w .java 2 s. c o m if (LOG.isDebugEnabled()) { LOG.debug("Redirecting to " + uri); } response.sendRedirect(response.encodeRedirectURL(uri)); }
From source file:com.emc.plants.web.servlets.AccountServlet.java
/** * send redirect//from w w w . j ava 2 s . co m */ private void sendRedirect(HttpServletResponse resp, String page) throws ServletException, IOException { resp.sendRedirect(resp.encodeRedirectURL(page)); }
From source file:org.jahia.bin.WelcomeServlet.java
protected void redirect(String url, HttpServletResponse response) throws IOException { String targetUrl = response.encodeRedirectURL(url); String jsessionIdParameterName = SettingsBean.getInstance().getJsessionIdParameterName(); if (targetUrl.contains(";" + jsessionIdParameterName)) { if (targetUrl.contains("?")) { targetUrl = StringUtils.substringBefore(targetUrl, ";" + jsessionIdParameterName + "=") + "?" + StringUtils.substringAfter(targetUrl, "?"); } else {/*from w w w. j ava 2 s .co m*/ targetUrl = StringUtils.substringBefore(targetUrl, ";" + jsessionIdParameterName + "="); } } WebUtils.setNoCacheHeaders(response); response.sendRedirect(targetUrl); }
From source file:org.muse.mneme.tool.TocView.java
/** * Handle the many cases of a post that completes the submission * /*from w ww . ja v a 2 s.co m*/ * @param req * Servlet request. * @param res * Servlet response. * @param context * The UiContext. * @param submissionId * the selected submission id. */ protected static void submissionCompletePost(HttpServletRequest req, HttpServletResponse res, Context context, String submissionId, UiService uiService, SubmissionService assessmentService) throws IOException { // if (!context.getPostExpected()) // { // // redirect to error // res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unexpected))); // return; // } // read form String destination = uiService.decode(req, context); if (destination.equals("SUBMIT")) { Submission submission = assessmentService.getSubmission(submissionId); // if linear, or the submission is all answered, we can go to submitted if ((!submission.getAssessment().getRandomAccess()) || (submission.getIsAnswered())) { destination = "/submitted/" + submissionId; // we will complete below } // if not linear, and there are unanswered parts, send to final review else { destination = "/final_review/" + submissionId; // we do not want to complete - redirect now res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); return; } } // we need to be headed to submitted... if (!destination.startsWith("/submitted")) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.invalidpost))); return; } Submission submission = assessmentService.getSubmission(submissionId); try { assessmentService.completeSubmission(submission); // if no exception, it worked! redirect res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); return; } catch (AssessmentClosedException e) { } catch (SubmissionCompletedException e) { } catch (AssessmentPermissionException e) { } // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); }
From source file:org.etudes.mneme.tool.ListView.java
/** * {@inheritDoc}/* w ww . j a v a2 s . co m*/ */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // read form String destination = this.uiService.decode(req, context); // go there res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }