tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phillip Morelock <subscripti...@phillipmorelock.com>
Subject Re: exception management with beans and Jsps
Date Fri, 17 May 2002 17:58:54 GMT
generally you should be using as few exceptions as possible...because they
are very expensive.

But if the API's you are using throw exceptions, and such, you should
definitely catch them at the bean level, and return negative or false values
to the jsp or whatever, and just use simple conditionals to test them.
Although, for particular exceptions, you might have specific conditions that
cause those, in which case you'll want to use error-page directives (like
SQL Exceptions if your database connection is lost, etc.).

Other people here can tell you perhaps how to make a particular error page
come out of particular errors...but that, you might have to do at the JSP
level, anyhow, in your case.

I personally find JSP inappropriate for complex error-handling and such (you
can do it, but damn it's ugly).  That's why you might want to look into the
MVC / "Model 2" type architecture, where you use servlets to handle complex
server-side code, and just use JSP for display.  This is another step in the
"fu" of java server coding, but it's made my life a lot easier since I just
went for it.  In a servlet, it's pure code, so you can just concentrate on
all your various error / invalid conditions, and handle them appropriately
by forwarding to different JSP's for display, etc.  JSP's are really married
to the way they look, and it's a lot harder to write a bunch of code in
there that's very flexible or extensible.

It looks like this:  user sends a request (maybe with some form data) -->
servlet processes it, scrubs everything, makes sure everything's cool -->
forwards to a JSP for display -- can be different jsp's depending on your
error conditions, etc.

My 2 cents.

fillup


On 5/17/02 10:47 AM, "Adam Pfeiffer" <adamcpfeiffer@yahoo.com> wrote:

> Does anyone know where I can find a good doc on how to handle exception with
> JSP and beans.  I
> would really like the bean to trap all the errors and set the messages and
> send those back to the
> jsp.  I am not sure how to do this.  I am still new with catching exceptions,
> so if my question
> doesn't make sense, I apologize in advance.
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message