Thanks all for the responses.
I got it working now =}

-----Original Message-----
From: Strachan, Paul [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 12, 2006 3:01 AM
To: Struts Users Mailing List
Subject: RE: default error page with tiles? (repost)

add something like this to your struts config...

  <global-exceptions>
    <exception handler="flc.handlers.GlobalExceptionHandler"
               type="java.lang.Exception" 
               key="errors.exception.system.unexpected" 
               path="flc.error" />
  </global-exceptions>

<code>
public class GlobalExceptionHandler extends ExceptionHandler {

    /*
     * Static Logger
     */
    private static Log        sLogger   =
LogFactory.getLog(GlobalExceptionHandler.class);

    public ActionForward execute(Exception ex,
                                 ExceptionConfig ae,
                                 ActionMapping mapping,
                                 ActionForm formInstance,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws ServletException {

        ActionForward forward = null;
        ActionMessage error = null;
        String property = null;

        // Build the forward from the exception mapping if it exists
        // or from the form input
        if (ae.getPath() != null) {
            forward = new ActionForward(ae.getPath());
        } else {
            forward = mapping.getInputForward();
        }

        // Figure out the error
        if (ex instanceof ModuleException) {
            error = ((ModuleException) ex).getActionMessage();
            property = ((ModuleException) ex).getProperty();
        } else {
            StringBuffer errorString = new StringBuffer();
            errorString.append(ex.getMessage() + ":");
            errorString.append("<br>");
            //create html string with stacktrace
            StackTraceElement[] stackTrace = ex.getStackTrace();
            for(int i=0; i < stackTrace.length; i++) {
                errorString.append(stackTrace[i].toString());
                errorString.append("<br>");
            }

            //log error
            sLogger.error(ex);
            error = new ActionMessage(ae.getKey(), errorString);
            property = error.getKey();
        }

        // Store the exception
        request.setAttribute(Globals.EXCEPTION_KEY, ex);
        storeException(request, property, error, forward,
ae.getScope());

        return forward;
    }

}
</code>

-----Original Message-----
From: Antonio Petrelli [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 12 September 2006 4:42 PM
To: Struts Users Mailing List
Subject: Re: default error page with tiles? (repost)

Darren Hall ha scritto:
> (Please disregard the earlier post with the same subject)
>
>  
>
> Greetings,
>
>  
>
> I'm using struts 1.2.9 with Tomcat 5.5 and Apache 2.2.
>
> Here's my issue -
>
> I'm looking to create a default error page for my application. One
thing you
> should know... my application is using tiles. In my web.xml file I've
added
> the following:
>
>   <!-- The default error page -->
>
>   <error-page>
>
>    <exception-type>java.lang.Exception</exception-type>
>
>    <location>flc.error</location>
>
>   </error-page>
>
> "flc.error" is a template definition for a tile layout.

Again, Tiles definitions cannot be accessed directly. You have to access

them through an ActionForward, a forward inside a regular action or 
inside a JSP page.

Ciao
Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************

---------------------------------------------------------------------
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