I'd like to create and use my own exception handler in GlassFish 2.
By default GlassFish uses the one predefined in web.xml:
Does anyone know any tutorial on creating and applying my own exception handler (to GlassFish)?
This might be considered a bad decision but I really need it.
I thought I would need to explicitly implement some kind of exception interface or method(s) with custom parameters, but in reality it turns out much simpler, you just create an usual servlet and change the web.xml file for errors to be sent to this servlet and what you do further is up to you.
Originally posted by James Greenberg:
Yeah I had a look at it but I don't need it, I only needed to catch the hideous Exception I get using Sun's JSF: when the session times out and the user clicks a submit-like button in a (JSF) form - the user gets a screen of errors and doesn't know what to do, I needed a way to catch that error and send the user to the main page in a user-friendly fashion. I tried to catch that Exception from "usual Java code" and nothing worked since the error raises inside the JSF implementation. I started thinking dropping JSF altogether or implementing my own exception handler. Luckily implementing it turned out to be much easier than I expected.
You want to handle ViewExpiredException? Just use the error-page directive of the web.xml for that.
About Tomcat v.s. Glassfish: I myself like Tomcat when it comes into development without the need for EJB's. Glassfish starts/restarts and debugs very slow, incredibly slow. Tomcat is small, lightweight and very quick. It starts and restarts within three seconds. But when EJB comes into picture, you may better consider JBoss AS, which is based on Tomcat, but has an EJB container on its top. Not as fast as Tomcat due to the EJB thing, but it's still faster than Glassfish.