You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Java Programmer <jp...@gmail.com> on 2008/05/07 09:30:04 UTC
How to generate 403 Forbidden?
Hello,
How can I generate 403 Forbidden or other codes (404 etc.) on
Exception? I think I should set headers and set redirect to true, but
anyone have working example?
Best regards,
Adr
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to generate 403 Forbidden?
Posted by Johan Compagner <jc...@gmail.com>.
ahh i looked to quickly :)
i though 1 does it more in the old way (AbortWithHttpStatusException)
and the AbortWithWebErrorCodeException with a much cleaner way of doing
(everything in a RequestTarget)
On Wed, May 7, 2008 at 9:45 AM, Eelco Hillenius <ee...@gmail.com>
wrote:
> > and we have 2:
> > AbortWithWebErrorCodeException
>
> Uses HttpServletResponse#sendError
>
> > AbortWithHttpStatusException
>
> Uses HttpServletResponse#setStatus
>
> > why 2? i dont know i think we need to clean up here.... (eelco? igor?
> who
> > was first ;) )
>
> From HttpServletResponse#setStatus:
>
> * Sets the status code for this response. This method is used to
> * set the return status code when there is no error (for example,
> * for the status codes SC_OK or SC_MOVED_TEMPORARILY). If there
> * is an error, and the caller wishes to invoke an error-page defined
> * in the web application, the <code>sendError</code> method should be
> used
> * instead.
> * <p> The container clears the buffer and sets the Location
> header, preserving
> * cookies and other headers.
>
> From HttpServletResponse#sendError:
>
> * Sends an error response to the client using the specified
> * status. The server defaults to creating the
> * response to look like an HTML-formatted server error page
> * containing the specified message, setting the content type
> * to "text/html", leaving cookies and other headers unmodified.
> *
> * If an error-page declaration has been made for the web application
> * corresponding to the status code passed in, it will be served back
> in
> * preference to the suggested msg parameter.
> *
> * <p>If the response has already been committed, this method throws
> * an IllegalStateException.
> * After using this method, the response should be considered
> * to be committed and should not be written to.
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: How to generate 403 Forbidden?
Posted by Eelco Hillenius <ee...@gmail.com>.
> and we have 2:
> AbortWithWebErrorCodeException
Uses HttpServletResponse#sendError
> AbortWithHttpStatusException
Uses HttpServletResponse#setStatus
> why 2? i dont know i think we need to clean up here.... (eelco? igor? who
> was first ;) )
>From HttpServletResponse#setStatus:
* Sets the status code for this response. This method is used to
* set the return status code when there is no error (for example,
* for the status codes SC_OK or SC_MOVED_TEMPORARILY). If there
* is an error, and the caller wishes to invoke an error-page defined
* in the web application, the <code>sendError</code> method should be used
* instead.
* <p> The container clears the buffer and sets the Location
header, preserving
* cookies and other headers.
>From HttpServletResponse#sendError:
* Sends an error response to the client using the specified
* status. The server defaults to creating the
* response to look like an HTML-formatted server error page
* containing the specified message, setting the content type
* to "text/html", leaving cookies and other headers unmodified.
*
* If an error-page declaration has been made for the web application
* corresponding to the status code passed in, it will be served back in
* preference to the suggested msg parameter.
*
* <p>If the response has already been committed, this method throws
* an IllegalStateException.
* After using this method, the response should be considered
* to be committed and should not be written to.
Eelco
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to generate 403 Forbidden?
Posted by Johan Compagner <jc...@gmail.com>.
for example InternalErrorPage already does that:
protected void configureResponse()
{
super.configureResponse();
getWebRequestCycle().getWebResponse().getHttpServletResponse().setStatus(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
and we have 2:
AbortWithWebErrorCodeException
AbortWithHttpStatusException
why 2? i dont know i think we need to clean up here.... (eelco? igor? who
was first ;) )
johan
On Wed, May 7, 2008 at 9:30 AM, Java Programmer <jp...@gmail.com>
wrote:
> Hello,
> How can I generate 403 Forbidden or other codes (404 etc.) on
> Exception? I think I should set headers and set redirect to true, but
> anyone have working example?
>
> Best regards,
> Adr
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: How to generate 403 Forbidden?
Posted by Iman Rahmatizadeh <im...@gmail.com>.
throw new AbortWithHttpStatusException(403,true);
Iman
On Wed, May 7, 2008 at 11:00 AM, Java Programmer <jp...@gmail.com>
wrote:
> Hello,
> How can I generate 403 Forbidden or other codes (404 etc.) on
> Exception? I think I should set headers and set redirect to true, but
> anyone have working example?
>
> Best regards,
> Adr
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>