You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stefan Lindner <li...@visionet.de> on 2008/10/07 10:35:42 UTC

How to answer Request with 500 error

I try to create a watchdog page for our site. My idea was to check the
neccessary resources and respond with a 500 error in case of failure.
So I placed

	
getWebRequestCycle().getWebResponse().getHttpServletResponse().setStatus
(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

in the page constructor and in onAfterRender but the page is displayed
correctly, no 500 error shown in browser.
Any idea?

Stefan

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


Re: How to answer Request with 500 error

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Also, see AbortWithHttpStatusException.


-- 
Jeremy Thomerson
http://www.wickettraining.com

On Tue, Oct 7, 2008 at 7:41 AM, Stefan Lindner <li...@visionet.de> wrote:

> Ah! Thank you.
>
> Stefan.
>
> -----Ursprüngliche Nachricht-----
> Von: Serkan Camurcuoglu [mailto:serkanc@telenity.com]
> Gesendet: Dienstag, 7. Oktober 2008 14:18
> An: users@wicket.apache.org
> Betreff: Re: How to answer Request with 500 error
>
> The WIA book says:
>
> Setting an HTTP status code:
> If you want to set an HTTP status code for your page, such as 404 (not
> found), you
> can do so by overriding the page's setHeaders method:
>
> @Override
> protected void setHeaders(WebResponse response) {
> response.getHttpServletResponse().setStatus(
> HttpServletResponse.SC_NOT_FOUND);
> super.setHeaders(response);
> }
>
> Alternatively, you can throw an AbortWithWebErrorCodeException and
> provide it
> with the appropriate error code and an optional message.
>
>
>
>
> Stefan Lindner wrote:
> > I try to create a watchdog page for our site. My idea was to check the
> > neccessary resources and respond with a 500 error in case of failure.
> > So I placed
> >
> >
> > getWebRequestCycle().getWebResponse().getHttpServletResponse().setStatus
> > (HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
> >
> > in the page constructor and in onAfterRender but the page is displayed
> > correctly, no 500 error shown in browser.
> > Any idea?
> >
> > Stefan
> >
> > ---------------------------------------------------------------------
> > 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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

AW: How to answer Request with 500 error

Posted by Stefan Lindner <li...@visionet.de>.
Ah! Thank you.

Stefan.

-----Ursprüngliche Nachricht-----
Von: Serkan Camurcuoglu [mailto:serkanc@telenity.com] 
Gesendet: Dienstag, 7. Oktober 2008 14:18
An: users@wicket.apache.org
Betreff: Re: How to answer Request with 500 error

The WIA book says:

Setting an HTTP status code:
If you want to set an HTTP status code for your page, such as 404 (not 
found), you
can do so by overriding the page's setHeaders method:

@Override
protected void setHeaders(WebResponse response) {
response.getHttpServletResponse().setStatus(
HttpServletResponse.SC_NOT_FOUND);
super.setHeaders(response);
}

Alternatively, you can throw an AbortWithWebErrorCodeException and 
provide it
with the appropriate error code and an optional message.




Stefan Lindner wrote:
> I try to create a watchdog page for our site. My idea was to check the
> neccessary resources and respond with a 500 error in case of failure.
> So I placed
>
> 	
> getWebRequestCycle().getWebResponse().getHttpServletResponse().setStatus
> (HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
>
> in the page constructor and in onAfterRender but the page is displayed
> correctly, no 500 error shown in browser.
> Any idea?
>
> Stefan
>
> ---------------------------------------------------------------------
> 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


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


Re: How to answer Request with 500 error

Posted by Serkan Camurcuoglu <se...@telenity.com>.
The WIA book says:

Setting an HTTP status code:
If you want to set an HTTP status code for your page, such as 404 (not 
found), you
can do so by overriding the page’s setHeaders method:

@Override
protected void setHeaders(WebResponse response) {
response.getHttpServletResponse().setStatus(
HttpServletResponse.SC_NOT_FOUND);
super.setHeaders(response);
}

Alternatively, you can throw an AbortWithWebErrorCodeException and 
provide it
with the appropriate error code and an optional message.




Stefan Lindner wrote:
> I try to create a watchdog page for our site. My idea was to check the
> neccessary resources and respond with a 500 error in case of failure.
> So I placed
>
> 	
> getWebRequestCycle().getWebResponse().getHttpServletResponse().setStatus
> (HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
>
> in the page constructor and in onAfterRender but the page is displayed
> correctly, no 500 error shown in browser.
> Any idea?
>
> Stefan
>
> ---------------------------------------------------------------------
> 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