List of usage examples for javax.servlet.http HttpServletResponse encodeRedirectUrl
@Deprecated
public String encodeRedirectUrl(String url);
From source file:org.etudes.mneme.tool.ExportDataView.java
/** * {@inheritDoc}/* w w w. ja v a2 s . co m*/ */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // [2]sort for /grades, [3]aid if (params.length != 4) throw new IllegalArgumentException(); // read form String destination = this.uiService.decode(req, context); res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }
From source file:org.etudes.mneme.tool.QuestionPreviewView.java
/** * {@inheritDoc}//www . j a va 2 s . c om */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // read form String destination = uiService.decode(req, context); // go there! res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }
From source file:org.muse.mneme.tool.ImportPoolView.java
/** * {@inheritDoc}//from w ww.jav a 2 s.c o m */ public void get(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // [2] pools sort if (params.length != 3) { throw new IllegalArgumentException(); } if (!this.poolService.allowManagePools(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } String poolsSort = params[2]; context.put("poolsSort", poolsSort); // render uiService.render(ui, context); }
From source file:org.wso2.carbon.identity.application.authentication.framework.AbstractLocalApplicationAuthenticator.java
/** * To get the redirect url when the user's account gets locked. * * @param context the authentication context * @param response the the httpServletResponse * @return redirect_url/* w ww.jav a2s.co m*/ */ protected String getRedirectUrlOnAccountLock(AuthenticationContext context, HttpServletResponse response) { String retryPage = ConfigurationFacade.getInstance().getAuthenticationEndpointRetryURL(); String queryParams = context.getContextIdIncludedQueryParams(); return response.encodeRedirectURL(retryPage + ("?" + queryParams)) + FrameworkConstants.STATUS_MSG + FrameworkConstants.ERROR_MSG + FrameworkConstants.STATUS + FrameworkConstants.ACCOUNT_LOCKED_MSG; }
From source file:fr.aliasource.webmail.server.LoginFilter.java
private String computeMyUrl(HttpServletRequest hreq, HttpServletResponse resp) { StringBuilder ret = new StringBuilder(hreq.getRequestURL().toString()); if (hreq.getQueryString() != null) { ret.append("?"); ret.append(hreq.getQueryString()); }//from w w w . jav a 2s .co m try { return URLEncoder.encode(resp.encodeRedirectURL(ret.toString()), "UTF-8"); } catch (UnsupportedEncodingException e) { return hreq.getRequestURL().toString(); } }
From source file:org.wso2.carbon.identity.application.authenticator.iwa.ntlm.IWAAuthenticator.java
public void sendToLoginPage(HttpServletRequest request, HttpServletResponse response, String ctx) throws AuthenticationFailedException { String iwaURL = null;//from w ww . j a v a 2 s .c o m 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) { log.error("Error when sending to the login page :" + iwaURL, e); throw new AuthenticationFailedException("Authentication failed"); } }
From source file:org.jsecurity.web.RedirectView.java
/** * Send a redirect back to the HTTP client * * @param request current HTTP request (allows for reacting to request method) * @param response current HTTP response (for sending response headers) * @param targetUrl the name URL to redirect to * @param http10Compatible whether to stay compatible with HTTP 1.0 clients * @throws IOException if thrown by response methods *//*from www . j av a2s .c o m*/ protected void sendRedirect(HttpServletRequest request, HttpServletResponse response, String targetUrl, boolean http10Compatible) throws IOException { if (http10Compatible) { // Always send status code 302. response.sendRedirect(response.encodeRedirectURL(targetUrl)); } else { // Correct HTTP status code is 303, in particular for POST requests. response.setStatus(303); response.setHeader("Location", response.encodeRedirectURL(targetUrl)); } }
From source file:org.xwoot.mockiphone.web.servlets.Bootstrap.java
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/* w w w .ja v a 2 s . com*/ if (MockIphoneSite.getInstance().isStarted()) { System.out.println("Site: " + MockIphoneSite.getInstance().getMockIphoneSiteEngine().getId() + " Bootstrap - instance already started"); response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/defaultApp.do")); return; } String errors = ""; String mockIphonePropertiesFile = request.getSession().getServletContext() .getRealPath(MockIphoneSite.MOCKIPHONE_PROPERTIES_FILENAME); if (request.getParameter("update") != null) { errors = MockIphoneSite.getInstance().updatePropertiesFiles(request, mockIphonePropertiesFile); // Start the MockIphone if the properties were correctly // saved. if (StringUtils.isBlank(errors)) { Properties p = MockIphoneSite.getInstance().getProperties(mockIphonePropertiesFile); MockIphoneSite.getInstance().init(p.getProperty(MockIphoneSite.IWOOT_END_POINT), p.getProperty(MockIphoneSite.MOCKIPHONE_DIR_NAME), new Integer(RandomUtils.nextInt(1000000) + 1000000).intValue()); System.out.println("Site :" + MockIphoneSite.getInstance().getMockIphoneSiteEngine().getId() + " Bootstrap - starting instance -"); response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/default.do")); return; } // There are errors, display the bootstrap page again. errors = errors.replaceAll("\n", "<br/>"); request.setAttribute("errors", errors); } if (!StringUtils.isBlank(mockIphonePropertiesFile)) { Properties p = MockIphoneSite.getInstance().updatePropertiesFromRequest(request, mockIphonePropertiesFile); request.setAttribute("properties", p); } request.getRequestDispatcher("/pages/Bootstrap.jsp").forward(request, response); return; } catch (Exception e) { System.out.println("EXCEPTION catched !!"); e.printStackTrace(); request.setAttribute("error", e.getMessage()); //request.getRequestDispatcher("/pages/Bootstrap.jsp").forward(request, response); return; } }
From source file:org.etudes.mneme.tool.ImportPoolView.java
/** * {@inheritDoc}/*from w ww . ja va 2 s . com*/ */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // [2] pools sort if (params.length != 3) { throw new IllegalArgumentException(); } if (!this.poolService.allowManagePools(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } // String poolsSort = params[2]; // read the form String destination = uiService.decode(req, context); res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }
From source file:org.etudes.mneme.tool.ImportPoolView.java
/** * {@inheritDoc}/*w w w .j av a 2 s . co m*/ */ public void get(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // [2] pools sort if (params.length != 3) { throw new IllegalArgumentException(); } if (!this.poolService.allowManagePools(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } String poolsSort = "0A"; if (params.length >= 3) poolsSort = params[2]; context.put("poolsSort", poolsSort); context.put("mneme", Boolean.TRUE); // render uiService.render(ui, context); }