Reputation: 33
I have a wicket page, and on the form submit I do a redirect to another page. I have this:
@Override
protected void onSubmit()
{
//Do something
response.sendRedirect(previousPageUrl);
}
The page was redirected correctly, but I got this exception:
[org.apache.wicket.protocol.http.WebResponse] [Unable to redirect to:..., HTTP Response has already been committed.]
[org.apache.wicket.protocol.http.WicketFilter] [closing the buffer error]
java.lang.IllegalStateException: Committed
at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1059) ~[na:na]
at org.eclipse.jetty.server.Response.sendRedirect(Response.java:449) ~[na:na]
at org.apache.wicket.protocol.http.WebResponse.sendRedirect(WebResponse.java:299) ~[wicket-1.4.17.jar:1.4.17]
at org.apache.wicket.protocol.http.WebResponse.redirect(WebResponse.java:250) ~[wicket-1.4.17.jar:1.4.17]
at org.apache.wicket.protocol.http.BufferedWebResponse.close(BufferedWebResponse.java:67) ~[wicket-1.4.17.jar:1.4.17]
I already tried to add this line before my sendRedirect()
call, but it didn't help:
getRequestCycleSettings().setRenderStrategy(IRequestCycleSettings.ONE_PASS_RENDER);
Upvotes: 0
Views: 1689
Reputation: 5681
You have to interrupt Wicket's request processing:
throw new RedirectToUrlException(previousPageUrl);
Upvotes: 1
Reputation: 584
My first initial impression on your code is that in your // do something
you might have written something to the response
object. You can try to do either commment those codes first to isolate the problem or paste the whole // do something
here so that we can you help you better.
Upvotes: 1