/** * Indicate sending of a redirectLocation to a particular named resource. This implementation * just keeps hold of the redirectLocation info and makes it available for query. * * @param location * The location to redirectLocation to * @throws IOException * Not used */ public void sendRedirect(String location) throws IOException { // If the location starts with ../ if (location.startsWith("../")) { // Test if the current url has a / in it. (a mount) String url = getURL(); int index = url.lastIndexOf("/"); if (index != -1) { // Then we have to recalculate what the real redirect is for the next request // which is just getContext() + getServletPath() + "/" + location; url = url.substring(0, index + 1) + location; url = RequestUtils.removeDoubleDots(url); // strip the servlet path again from it. index = url.indexOf("/"); location = url.substring(index + 1); } } redirectLocation = location; }
/** * Indicate sending of a redirectLocation to a particular named resource. This implementation * just keeps hold of the redirectLocation info and makes it available for query. * * @param location * The location to redirectLocation to * @throws IOException * Not used */ public void sendRedirect(String location) throws IOException { // If the location starts with ../ if (location.startsWith("../")) { // Test if the current url has a / in it. (a mount) String url = getURL(); int index = url.lastIndexOf("/"); if (index != -1) { // Then we have to recalculate what the real redirect is for the next request // which is just getContext() + getServletPath() + "/" + location; url = url.substring(0, index + 1) + location; url = RequestUtils.removeDoubleDots(url); // stril the servlet path again from it. index = url.indexOf("/"); location = url.substring(index + 1); } } redirectLocation = location; }
/** * Initialize the request parameters from the given redirect string that redirects back to a * particular component for display. * * @param redirect * The redirect string to display from */ public void setRequestToRedirectString(final String redirect) { parameters.clear(); int queryStringPos = redirect.indexOf('?'); // Decode the parameters if (queryStringPos != -1) { final String queryString = redirect.substring(queryStringPos + 1); RequestUtils.decodeParameters(queryString, parameters); } // We need to absolutize the redirect URL as we are not as smart as a web-browser // (WICKET-702) url = redirect; if ((url.length() == 0) || (url.charAt(0) != '/')) { url = getContextPath() + getServletPath() + "/" + redirect; } // Remove occurrences of ".." from the path url = RequestUtils.removeDoubleDots(url); log.info("Redirecting to " + url); }
/** * Initialize the request parameters from the given redirect string that redirects back to a * particular component for display. * * @param redirect * The redirect string to display from */ public void setRequestToRedirectString(final String redirect) { parameters.clear(); int queryStringPos = redirect.indexOf('?'); // Decode the parameters if (queryStringPos != -1) { final String queryString = redirect.substring(queryStringPos + 1); RequestUtils.decodeParameters(queryString, parameters); } // We need to absolutize the redirect URL as we are not as smart as a web-browser // (WICKET-702) url = getContextPath() + getServletPath() + "/" + redirect; // Remove occurrences of ".." from the path url = RequestUtils.removeDoubleDots(url); log.info("Redirecting to " + url); }