struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Givler, Eric" <>
Subject RE: global exceptions, key?
Date Thu, 28 Sep 2006 11:57:16 GMT
Here's the steps I did to test this, which worked:

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

    <exception type="java.lang.Exception" 

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:
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"
<%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>
<%@ page contentType="text/html;charset=windows-1252" isErrorPage="true" %>
<%@ page import="org.apache.struts.Globals" %>         
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>

        // 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() ); 

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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.apache.struts.actions.DispatchAction.dispatchMethod(
	at org.apache.struts.actions.DispatchAction.execute(
	at org.apache.struts.actions.LookupDispatchAction.execute(
	at org.apache.struts.action.RequestProcessor.processActionPerform(
	at org.apache.struts.action.RequestProcessor.process(
	at org.apache.struts.action.ActionServlet.process(
	at org.apache.struts.action.ActionServlet.doPost(
      [rest of stack trace remove]

-----Original Message-----
From: []
Sent: Thursday, September 28, 2006 3:05 AM
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:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message