@Override public void respond(IRequestCycle requestCycle) { String location = url.toString(); if (location.startsWith("/")) { // context-absolute url location = requestCycle.getUrlRenderer().renderContextRelativeUrl(location); } if (config.isPreferStateful()) { // we need to persist the session before a redirect to https so the session lasts // across both http and https calls. Session.get().bind(); } WebResponse response = (WebResponse) requestCycle.getResponse(); response.sendRedirect(location); }
/** * @see * org.apache.wicket.core.request.handler.IPageRequestHandler#respond(org.apache.wicket.request.IRequestCycle) */ @Override public final void respond(final IRequestCycle requestCycle) { final RequestCycle rc = (RequestCycle) requestCycle; final WebResponse response = (WebResponse) requestCycle.getResponse(); if (shouldRedirectToPage(requestCycle)) { // the page itself has been added to the request target, we simply issue a redirect // back to the page IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page)); final String url = rc.urlFor(handler).toString(); response.sendRedirect(url); return; } respondersFrozen = true; for (ITargetRespondListener listener : respondListeners) { listener.onTargetRespond(this); } final Application app = page.getApplication(); page.send(app, Broadcast.BREADTH, this); // Determine encoding final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding(); // Set content type based on markup type for page update.setContentType(response, encoding); // Make sure it is not cached by a client response.disableCaching(); final StringResponse bodyResponse = new StringResponse(); update.writeTo(bodyResponse, encoding); CharSequence filteredResponse = invokeResponseFilters(bodyResponse); response.write(filteredResponse); }