struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harland, David" <David.Harl...@dlapiper.com>
Subject How do you create a ExceptionHandler and error.jsp page
Date Wed, 29 Jun 2005 13:22:33 GMT
Hi,

I have written an ExceptionHandler below and error.jsp page below but
the error page is not displaying the error. Can anyone see why please?

Thanks

Dave.

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.*;
import org.apache.struts.config.ExceptionConfig;


public final class ActionExceptionHandler extends ExceptionHandler {

  public ActionForward execute(Exception ex,
                                  ExceptionConfig config,
                                  ActionMapping mapping,
                                  ActionForm formInstance,
                                  HttpServletRequest request,
                                  HttpServletResponse response)
    throws ServletException {
    ActionForward forward = null;
    ActionMessage message = null;
    String property = null;

    /* Get the path for the forward either from the exception element
    * or from the input attribute.
    */
    String path = null;
    if(config.getPath() != null) {
      path = config.getPath();
    }
    else {
      path = mapping.getInput();
    }

    // Construct the forward object
    forward = new ActionForward(path);

    message = new ActionMessage(config.getKey());
    property = message.getKey();

    // Store the ActionError into the proper scope

    // The storeException method is defined in the parent class

    storeException(request, property, message, forward,
config.getScope());
    return forward;
  }
}


<%@page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html locale="true">

<br>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
  <logic:messagesPresent message="true">
  <html:messages id="message" message="true">
  <tr>
    <td>&nbsp;</td>
    <td colspan="8" class="style1"><font color="red"><li><bean:write
name="message"/></li></font></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="8" class="style1">&nbsp;</td>
    <td>&nbsp;</td>
  </tr></html:messages></logic:messagesPresent> 
</table>



</body>
</html:html>

This e mail is from DLA Piper Rudnick Gray Cary UK LLP.

The contents of this email and any attachments are confidential to the intended recipient.
They may not be disclosed to or used by or copied in any way by anyone other than the intended
recipient. If this email is received in error, please contact DLA Piper Rudnick Gray Cary
UK LLP on +44 (0) 8700 111111 quoting the name of the sender and the email address to which
it has been sent and then delete it.

Please note that neither DLA Piper Rudnick Gray Cary UK LLP nor the sender accept any responsibility
for viruses and it is your responsibility to scan or otherwise check this email and any attachments.


DLA Piper Rudnick Gray Cary UK LLP is a limited liability partnership registered in England
and Wales (registered number OC307847) which provides services from offices in England, Belgium,
Germany and the People's Republic of China.  A list of members is open for inspection at its
registered office and principal place of business 3 Noble Street, London EC2V 7EE.  Partner
denotes member of a limited liability partnership.

DLA Piper Rudnick Gray Cary UK LLP is regulated by the Law Society and is a member of DLA
Piper Rudnick Gray Cary, a global legal services organisation, the members of which are separate
and distinct legal entities.  For further information, please refer to www.dlapiper.com.




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message