----- Original Message ----- 
From: "Adam Pfeiffer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 15, 2002 8:11 PM
Subject: How to end a JSP


> If you have a try/catch block in a jsp and you catch an error that is know to cause 
>the page not
> to function, how can you gracefully skip the rest of the jsp page and print an error 
>message.  For
> example, in the below code pictureBrowserBean.parseAlbums(); is going to throw a 
>null pointer
> exception.  I want the catch block to print an error message and quit running the 
>jsp.  How do I
> do this?

:-)

Throw an exception.

The only way to abort and already written ServletResponse object is to cause the page 
not to finish it's service() method and even that can fail if buffer was already 
(partially) commited. But, anyway, throwing an exception is the way. You can configure 
Tomcat to use custom ErrorPages for a specific JSP page or an exception class.

Nix.


Reply via email to