If your just going for exception information you can direct to a JSP page 
and use the Struts tags and look directly at the attributes defined o the 
Exception implementation.
<struts:property value="exception.message"/> 
<struts:property value="exception.cause.class"/> 

etc..


Matt Filion
[EMAIL PROTECTED]


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please 
delete without copying and kindly advise us by e-mail of the mistake in 
delivery. NOTE: Regardless of content, this e-mail shall not operate to 
bind CSC to any order or other contract unless pursuant to explicit 
written agreement or government initiative expressly permitting the use of 
e-mail for such purpose.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




"Neil Aggarwal" <[EMAIL PROTECTED]> 
09/10/2007 07:46 AM
Please respond to
"Struts Users Mailing List" <user@struts.apache.org>


To
"'Struts Users Mailing List'" <user@struts.apache.org>
cc

Subject
How to get exception in action class for error page?






Hello:

I declared an application error page in my web.xml:

  <error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/error.action</location>
  </error-page>

I have this declaration in my struts.xml:

    <action name="error" class="page.Error">
      <result name="success" type="tiles">error</result>
    </action>

In my page.Error class, I am trying to get the exception
that was thrown:

public class Error extends ActionSupport {
  public String execute() {
    PageContext pageContext = ServletActionContext.getPageContext();
    if( pageContext != null ) {
      Exception exception = pageContext.getException();
      if( exception != null ) {
        Logger.getLogger(getClass()).error(exception);
      }
    } else {
      Logger.getLogger(getClass()).debug("Page context is null");
    }
    return SUCCESS;
  }
}

But, when the action executes, the pageContext is always null.

What can I do to get the exception that was thrown?

Thanks,
                 Neil

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.


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


Reply via email to