I've reduced my real problem to a simple somepackage.CustomException example. In my real application, there are actions, such:
<action path = "/_spikeAction_3rdLayerEx" validate = "false" scope = "request" name = "spikeAction_3rdLayerEx" type = "_spikes.ownactions.SpikeAction_3rdLayerEx"> </action> where the action class is: public final class SpikeAction_3rdLayerEx extends Action { private static Logger logger = Logger.getLogger(SpikeAction_3rdLayerEx.class.getName()); public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { /* * some our code that can throw checked exception.... */ throw new Exception("3rd layer exception", new Exception("the cause")); } catch (Exception e) { logger.log(Level.SEVERE, "log 3rd layer exceptions and forward to error page", e); throw e; } // return null; } } this works well, when in web.xml is: <error-page> <error-code>500</error-code> <location>/ErrorPage_3rdLayer.jsp</location> </error-page> so the page ErrorPage_3rdLayer.jsp is displayed. But how can i configure the environment to display mentioned error page every time when AnyException extends Exception (or extends RuntimeException) occurs, no matter whether in an action or jsp page simply browsed by browser? The second problem is that i have some BaseActionForm extends ActionForm, which has got the method validate. When an Exception (ClientException, or RemoteException, or RuntimeException) occurs in this method, sturts don't display error page. It is possible this situation is caused by wrong design of the application, which is in progress of development. Zarar Siddiqi wrote: > > Struts isn't catching this exception because you're throwing it in a > JSP page which is being accessed outside the Struts servlet (directly > via a URL). > > Try throwing the exception in a Struts action and see what happens. > But even if you do that you'll run into a problem with the current > setup. You're asking Struts to "intercept" an exception called > somepackage.CustomException but are throwing java.lang.Exception. So > Struts will just ignore it since the thrown exception is not a > CustomException. Try throwing CustomException instead of Exception OR > change your Struts config to look for java.lang.Exception. > > Zarar > > On 8/13/07, Marek Cupak <[EMAIL PROTECTED]> wrote: >> >> i need to configure struts to display user a errpage.jsp, when runtime >> exception CustomException occur anywhere in the application. i've added >> to >> struts-config: >> >> <global-exceptions> >> <exception key="exception.Exception" >> type="somepackage.CustomException" >> path="/ErrorPage.jsp"/> >> </global-exceptions> >> >> and to web.xml: >> >> <error-page> >> <error-code>500</error-code> >> <location>/ErrorPage.jsp</location> >> </error-page> >> >> when i browse page _spikeScriptletThrowingEx.jsp: >> >> <%@ page language="java" contentType="text/html; charset=UTF-8" >> pageEncoding="UTF-8"%> >> <html> >> <head> >> <title></title> >> </head> >> <body> >> <% throw new Exception(); %> >> </body> >> </html> >> >> i receive only "The website cannot display the page, HTTP 500...". why is >> the ErrorPage.jsp not displayed? >> >> -- >> View this message in context: >> http://www.nabble.com/global-exception-handling---struts-sometimes-ignores-my-setting-in-struts-config%2C-what%27s-wrong--tf4261735.html#a12127828 >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/global-exception-handling---struts-sometimes-ignores-my-setting-in-struts-config%2C-what%27s-wrong--tf4261735.html#a12139698 Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]