struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <Wendy.Sm...@asu.edu>
Subject RE: [OT] Handling database connection exceptions
Date Mon, 17 Nov 2003 22:52:04 GMT
> 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>
      <exception-type>javax.servlet.ServletException</exception-type>
      <location>/WEB-INF/jsp/exceptionServlet.jsp</location>
   </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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message