You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Yansheng Lin <ya...@isogis.com> on 2003/12/12 22:27:09 UTC

Tomcat Exception Handling =?= Web Tier Exception Handling

Hi, I am having a bit of problem setting up my exception handling hierarchy. I
know you can use the error-page attribute in web.xml to handle system error.
But I read somewhere that one should always distance himself from system-level
exception handling when it comes to web applications.  

		<error-page>
			<error-code>500</error-code>
			<location>serverError.jsp</location>
		</error-page>
		<error-page>
	
<exception-type>java.lang.NullPointerException</exception-type>
			<location>nullError.jsp</location>
		</error-page>

My question is, should I use tomcat exception handling mechanism, or should I
come up with my own exception handling framework?  Maybe I should use both, but
I am not very keen on spending time on exceptions right now(need to get the
alpha release out as soon as possible)....
Any suggestions?

-Yan



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


Re: Tomcat Exception Handling =?= Web Tier Exception Handling

Posted by QM <qm...@brandxdev.net>.
: My question is, should I use tomcat exception handling mechanism, or should I
: come up with my own exception handling framework?

A lot of this depends on your app's setup and how thorough/robust you
expect your handling to be as it grows.

1/ Quick-And-Dirty: map a "something went wrong" page to
java.lang.Throwable in web.xml.  Come back and design something more
robust after your alpha's out the door.

2/ Slightly Better: same as above, but wrap system exceptions in custom
exceptions and pull a message from a known request-scope key to print to
the browser.  You can evaluate for yourself whether you'd want to build
on this general idea, e.g. special error pages for special errors and a
generic page for generic errors.  There are innumerable variations on
this theme but you get the gist.

3/ If you're using Struts: there's some handy exception-handling built
in.  It works quite well for me.  It may work for you.  I haven't used
other frameworks but chances are they'd have something similar.

I do #3 for my larger, Struts-based apps and something similar to #2 for
the quick demos.  

-QM

--

software  -- http://www.brandxdev.net (C++ / Java / SSL)
tech news -- http://www.RoarNetworX.com


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