List of usage examples for javax.servlet.http HttpServletResponse encodeRedirectUrl
@Deprecated
public String encodeRedirectUrl(String url);
From source file:at.gv.egovernment.moa.id.proxy.servlet.ProxyServlet.java
private static void generateErrorAndRedirct(HttpServletResponse resp, String errorURL, String message) { try {// w w w . j a v a 2s. c om errorURL = addURLParameter(errorURL, PARAM_ERRORMASSAGE, URLEncoder.encode(message, "UTF-8")); } catch (UnsupportedEncodingException e) { errorURL = addURLParameter(errorURL, PARAM_ERRORMASSAGE, "Fehlermeldung%20konnte%20nicht%20%C3%BCbertragen%20werden."); } errorURL = resp.encodeRedirectURL(errorURL); resp.setContentType("text/html"); resp.setStatus(302); resp.addHeader("Location", errorURL); }
From source file:org.etudes.mneme.tool.ImportQtiView.java
/** * {@inheritDoc}//w w w.j ava 2 s .c om */ public void get(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { if (!this.poolService.allowManagePools(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } String returnUrl = (params.length > 3) ? params[2] : ""; String sort = (params.length > 3) ? params[3] : "0A"; context.put("returnUrl", returnUrl); context.put("sort", sort); // render uiService.render(ui, context); }
From source file:org.apache.cocoon.servlet.RequestUtil.java
/** * Same as {@link #getCompleteUri(HttpServletRequest, HttpServletResponse)} but * disregards {@link HttpServletRequest#getServletPath()}. * * <br>Used by {@link SitemapServlet}. *//* w w w . j a v a 2s . com*/ public static String getCompleteBlockUri(HttpServletRequest request, HttpServletResponse response) throws IOException { // The original implementation prepend the servlet context path which doesn't work // in the tree processor if there actually is a servlet context path // VG: ...but still need to know if servlet path had a '/' at the end // (in case if path info is empty, need to know whether to issue a redirect or not) String servletPath = request.getServletPath(); if (servletPath == null) { servletPath = ""; } String uri = request.getPathInfo(); if (uri == null) { uri = ""; } if (uri.length() == 0 && !servletPath.endsWith("/")) { /* * Empty relative URI. Issue HTTP redirect from '/block' to '/block/' to * avoid breaking relative URIs in the response generated by the sitemap * which expects to be mounted at '.../'. */ String serverAbsoluteUri = request.getRequestURI(); if (serverAbsoluteUri == null) { serverAbsoluteUri = "/"; } else { serverAbsoluteUri += "/"; } response.sendRedirect(response.encodeRedirectURL(serverAbsoluteUri)); return null; } if (uri.length() > 0 && uri.charAt(0) == '/') { return uri.substring(1); } return uri; }
From source file:org.etudes.mneme.tool.AssessmentsRestoreView.java
/** * {@inheritDoc}/* ww w .ja v a2 s .c o m*/ */ 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; } // we carry a sort for the /tests mode String sort = ""; if (params.length == 3) { sort = params[2]; } context.put("sort", sort); // collect the archived assessments in this context List<Assessment> assessments = this.assessmentService .getArchivedAssessments(this.toolManager.getCurrentPlacement().getContext()); context.put("archived", assessments); // render uiService.render(ui, context); }
From source file:org.wso2.carbon.identity.application.authenticator.iwa.AbstractIWAAuthenticator.java
/** * Redirect to the IWA servlet with the authentication context information * * @param request//from w w w.j a va2 s . c o m * @param response * @param ctx Authentication context identifier * @throws AuthenticationFailedException */ private void sendToLoginPage(HttpServletRequest request, HttpServletResponse response, String ctx) throws AuthenticationFailedException { String iwaURL = null; try { iwaURL = IdentityUtil.getServerURL(IWAConstants.IWA_AUTH_EP, false, true) + "?" + IWAConstants.IWA_PARAM_STATE + "=" + URLEncoder.encode(ctx, IWAConstants.UTF_8); response.sendRedirect(response.encodeRedirectURL(iwaURL)); } catch (IOException e) { String msg = "Error when redirecting to the login page : " + iwaURL; throw new AuthenticationFailedException(msg, e); } }
From source file:org.etudes.mneme.tool.GradesView.java
/** * {@inheritDoc}//ww w. j a v a2 s . c om */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // security if (!this.submissionService.allowEvaluate(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } // read the form String destination = uiService.decode(req, context); res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }
From source file:org.carrot2.webapp.RootRedirectFilter.java
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) req; final HttpServletResponse response = (HttpServletResponse) resp; final String contextPath = request.getContextPath(); final String uri = request.getRequestURI().substring(contextPath.length()); if ("/".equals(uri) || StringUtils.isEmpty(uri)) { // According to the spec, this is a temporary redirect -- fine by us. response.sendRedirect(request.getContextPath() + response.encodeRedirectURL(targetURI)); } else {/* w ww . ja v a 2 s . c o m*/ chain.doFilter(req, resp); } }
From source file:org.etudes.mneme.tool.AssessmentsRestoreView.java
/** * {@inheritDoc}/* w ww . ja v a 2 s.c om*/ */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // security check if (!assessmentService.allowManageAssessments(this.toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } // for the selected tests to delete Values values = this.uiService.newValues(); context.put("ids", values); // read the form String destination = uiService.decode(req, context); // restore for (String id : values.getValues()) { Assessment assessment = this.assessmentService.getAssessment(id); if (assessment != null) { assessment.setArchived(Boolean.FALSE); try { this.assessmentService.saveAssessment(assessment); } catch (AssessmentPermissionException e) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } catch (AssessmentPolicyException e) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.policy))); return; } } } res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }
From source file:org.etudes.mneme.tool.GuestListView.java
/** * {@inheritDoc}//from w w w .j a va 2 s. c om */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // check security if (!assessmentService.allowGuest(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } // read form String destination = this.uiService.decode(req, context); // go there res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }
From source file:org.wso2.carbon.identity.application.authenticator.iwa.IWAAuthenticator.java
public void sendToLoginPage(HttpServletRequest request, HttpServletResponse response, String ctx) throws AuthenticationFailedException { String iwaURL = null;//w w w . j a v a 2 s.c o m try { iwaURL = IdentityUtil.getServerURL(IWAConstants.IWA_AUTH_EP) + "?" + IWAConstants.IWA_PARAM_STATE + "=" + URLEncoder.encode(ctx, IWAConstants.UTF_8); response.sendRedirect(response.encodeRedirectURL(iwaURL)); } catch (IOException e) { log.error("Error when sending to the login page :" + iwaURL, e); throw new AuthenticationFailedException("Authentication failed"); } }