Hi,

On Sat, Feb 25, 2012 at 12:20 AM, Neil Curzon <[email protected]> wrote:
> Hi all,
>
> We've been using an IRequestCycleListener in order to redirect to a certain
> page for all requests if certain conditions are met. We're finding that
> it's giving an exception in 1.5.4:
>
> java.lang.IllegalStateException: Header was already written to response!
> at
> org.apache.wicket.protocol.http.HeaderBufferingWebResponse.checkHeader(HeaderBufferingWebResponse.java:64)
> at
> org.apache.wicket.protocol.http.HeaderBufferingWebResponse.setDateHeader(HeaderBufferingWebResponse.java:134)
> at
> org.apache.wicket.protocol.http.BufferedWebResponse$SetDateHeaderAction.invoke(BufferedWebResponse.java:310)
> at
> org.apache.wicket.protocol.http.BufferedWebResponse.writeTo(BufferedWebResponse.java:580)
> at
> org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:185)
> at
> org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:167)
> at
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:781)
>
> basically in our IRequestCycleListener we have
>
> @Override
> public void onBeginRequest(RequestCycle cycle) {
> if (<condition>)) {
> cycle.setResponsePage(SpecificPage.class);

better use: throw new RestartResponseException()

this will both save you some CPU cycles and additionally will reset
the WebResponse (drop any set headers and body)

> }
> }
>
> Is this the wrong way to do it? Or is this behavior expected? If it's not
> expected, I will file a bug for this.
>
> Thanks,
> Neil



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to