struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yee, Richard K,,DMDCWEST" <>
Subject RE: [OT] Handling database connection exceptions
Date Mon, 17 Nov 2003 23:21:38 GMT
Where in your JSP does the NullPointerException occur? Is it in a method
call in a scriptlet? If so, your JSP is still indirectly accessing the
database. What Wendy suggested was that the the database access class be
invoked from your DisplactAction class and the results be put in a
collection and set as an attribute in the request. That way, any problems
with getting the data would be caught in your Action class and then you
could forward to an error page.

Otherwise, why can't you just specify an error page using the errorPage
attribute in your JSP's <%@page ...> tag?


-----Original Message-----
From: Shyam A [] 
Sent: Monday, November 17, 2003 3:10 PM
To: Struts Users Mailing List
Subject: RE: [OT] Handling database connection exceptions


Thanks for your mail. I don't know if you fully
understood where I'm coming from! As I said, the
database connection is accessed from a Data Access
class (read model), which is called from my
DispatchAction class. Since the exception is not
caught in my DispatchAction class (the methods throw Exception), it is
propagated to my JSP's. It doesn't mean my JSP's directly access the

Anyway, thanks for your help.


--- Wendy Smoak <> wrote:
> > I have a Database servlet configured in web.xml,
> which
> > intialises a connection pool on Server startup.
> > However, if the data source is unavailable, I get
> a
> > "Null Pointer" exception on my JSPs, which is
> > propagated from my Data Access class.
> IMO, the problem is that you're accessing the
> database from the JSP.
> And this, in a Struts webapp?!  The view has no
> business talking to the
> model.
> If you move the data access to the Action, then you
> can catch the error
> and gracefully forward to an error page.
> Meanwhile, you can define error pages in web.xml so
> that your users
> don't see the stack trace.  For example, I have
> this:
>    <error-page>
>    </error-page>
> which gives the user an apology and a phone number
> to call.
> --
> Wendy Smoak
> Applications Systems Analyst, Sr.
> Arizona State University, PA, IRM 
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message