This page applies to Wicket 1.2.
Normally, you'd use one of the following to redirect to a Wicket page:
setResponsePage(new FooPage(arg0, arg1)); setResponsePage(BarPage.class);
If you're trying to integrate with JSPs or similar, you may need to redirect to a non-Wicket page. There's a Response.redirect() method for doing this, but you need to jump through a couple of hoops to make it work, like so:
public void onSubmit() { // [...] // Tell Wicket we're going to do the redirect ourselves. getRequestCycle().setRedirect(false); // Make sure no output for the current cycle is ever sent. getRequestCycle().setRequestTarget(EmptyRequestTarget.getInstance()); // The HTTP RFC says redirects should always be absolute, so we // make an absolute path by prefixing with the context path. String contextPath = getApplication().getApplicationSettings().getContextPath(); getResponse().redirect(contextPath + "/path/to/legacyJspFile.jsp"); }
Note that if you just want to make standard anchor tag links to other pages, don't create a Link and use this method in the onClick() handler; instead use the ExternalLink class.