You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Funk <ma...@gmail.com> on 2013/07/02 15:58:34 UTC

Save place to set http response status?

Hi there,

what is the best place to set http response state?

I was trying the 'onSomething' callback methods in IRequestCycleListener
Like onEndRequest

But sometimes those get ignored

The last save place I figured was onAfterRender in the page class, but this doesn't feel right.

The reason that calls like:
((HttpServletResponse) RequestCycle.get().getResponse().getContainerResponse()).setStatus(404);
in the RequestCycle Listner are ignored seems to be that the underlying container, Tomcat 6.0.37 in our case, starts to flush the outputstream as the Response becomes big, as in maybe 20k.

If the response is small enoug the status, can be set up to  'onDetach()'

Anyone any ideas?

Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: Save place to set http response status?

Posted by Paul Bors <pa...@bors.ws>.
I think you might be interested in WebResponse#setStatus(int):
http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/request/h
ttp/WebResponse.html#setStatus%28int%29

As an example see:
http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/markup/ht
ml/pages/AccessDeniedPage.html

And its source code as part of the wicket-core module:
https://github.com/apache/wicket/blob/build/wicket-6.9.0/wicket-core/src/mai
n/java/org/apache/wicket/markup/html/pages/AccessDeniedPage.java

Or simply pull up its call hierarchy in your IDE.

~ Thank you,
  Paul Bors

-----Original Message-----
From: Martin Funk [mailto:mafulafunk@gmail.com] 
Sent: Tuesday, July 02, 2013 9:59 AM
To: users@wicket.apache.org
Subject: Save place to set http response status?

Hi there,

what is the best place to set http response state?

I was trying the 'onSomething' callback methods in IRequestCycleListener
Like onEndRequest

But sometimes those get ignored

The last save place I figured was onAfterRender in the page class, but this
doesn't feel right.

The reason that calls like:
((HttpServletResponse)
RequestCycle.get().getResponse().getContainerResponse()).setStatus(404);
in the RequestCycle Listner are ignored seems to be that the underlying
container, Tomcat 6.0.37 in our case, starts to flush the outputstream as
the Response becomes big, as in maybe 20k.

If the response is small enoug the status, can be set up to  'onDetach()'

Anyone any ideas?

Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org