You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Martin Strand <ma...@entcap.se> on 2006/09/24 03:49:00 UTC

Send 404 on PageNotFoundException

I want to make the servlet container show its standard 404 page instead of  
the exception page on PageNotFoundExceptions. I assume I'll need to write  
a custom ExceptionPresenter, but from there, how do I tell the servlet  
container to send a 404?

Thanks,
Martin

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


Re: Send 404 on PageNotFoundException

Posted by Martin Strand <ma...@entcap.se>.
It wasn't that hard. :)
Something like this:

public class CustomExceptionPresenter
	extends ExceptionPresenterImpl
	implements ExceptionPresenter
{
	private WebResponse response;

	public CustomExceptionPresenter(WebResponse response)
	{
		this.response = response;
	}

	@Override
	public void presentException(IRequestCycle cycle, Throwable t)
	{
		if (t instanceof PageNotFoundException)
		{
			response.setStatus(404);
		}
		super.presentException(cycle, t);
	}
}

On Sun, 24 Sep 2006 03:49:00 +0200, Martin Strand  
<ma...@entcap.se> wrote:

> I want to make the servlet container show its standard 404 page instead  
> of the exception page on PageNotFoundExceptions. I assume I'll need to  
> write a custom ExceptionPresenter, but from there, how do I tell the  
> servlet container to send a 404?
>
> Thanks,
> Martin

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