Here's the steps I did to test this, which worked:

1. modify struts-config.xml for an exception handler:

  <global-exceptions>
    <exception type="java.lang.Exception" 
               path="/Error_Page.jsp" 
               key="exception.servletexception" 
               scope="request"/>
  </global-exceptions>

2. Force an exception in some action:

try { int i = 1/ 0; 
}
catch ( Exception ex ) {
   throw new ServletException("general failure error reading drive C");
}

3. Add entry to resources file: project1.ApplicationResources.properties
as defined by struts-config.xml:
 <message-resources parameter="project1.ApplicationResources"/>

exception.servletexception=A catastrophic error occurred.

4. Defined an error page: Error_Page.jsp:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>
<%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>
<%@ page contentType="text/html;charset=windows-1252" isErrorPage="true" %>
<%@ page import="org.apache.struts.Globals" %>         
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    <title>Error_Page</title>
  </head>
  <body>
     <html:errors/>
     <br/>

     <% 
        // read the Struts exception that is placed here by the default Struts 
Exception handler.
        Exception e2 = (Exception) request.getAttribute( Globals.EXCEPTION_KEY 
);
        if ( e2 != null ) {
           // out.println( e2.getLocalizedMessage() ); 
           e2.printStackTrace(new java.io.PrintWriter(out)); 
        }
      %>
   </body>
</html>

5. test application:

Validation Error
You must correct the following error(s) before proceeding:
A catastrophic error occurred.

     javax.servlet.ServletException: general failure error reading drive C
        at 
struts.apache.org.actions.DependentListAction.refreshList(DependentListAction.java:51)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
        at 
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
        at 
org.apache.struts.actions.LookupDispatchAction.execute(LookupDispatchAction.java:150)
        at 
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        at 
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        at 
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:434)
      [rest of stack trace remove]


-----Original Message-----
From: Andy.de [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 28, 2006 3:05 AM
To: user@struts.apache.org
Subject: RE: global exceptions, key?





Givler, Eric wrote:
> 
> I'm pretty sure the error.message1 key which is looked up in the resource
> file can be displayed in the resulting jsp with:
> <html:errors/>
> 
> 

Hi Eric,
thats what i tried but it don't work
Regards, Andy
-- 
View this message in context: 
http://www.nabble.com/global-exceptions%2C-key--tf2343367.html#a6541281
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]

Reply via email to