You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Zhang, Larry (L.)" <lz...@ford.com> on 2003/09/30 21:13:05 UTC

configure default error page in web.xml

HI,

I have a request to catch a Java Exception in the servlet and display an error page. The functionality requires that we display different error message for different exception.

A way to do this is to put try and catch logic in servlet, and if an Exception is caught, I do request.setAttribute("javax.servlet.jsp.jspExcetion",e), and then forward to jsp error page, where we check the type of exception implicit object. Based on this type, we display different error message. This is fine, but we are not going to use this approach.

The other way is to configure web.xml. We can configure an error page for specific Java exception. If the specific exception is raised to the web container, the configured error page will get called. My question is that is there any body  doing this way successfully?

Thanks.

Larry Zhang


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


RE: configure default error page in web.xml

Posted by Kris Schneider <kr...@dotech.com>.
You can certainly combine approaches to let a Struts action handle pretty much
any exception in the app. In web.xml:

<error-page>
  <exception-type>java.lang.Exception</exception-type>
  <location>/do/error</location>
</error-page>

Where "/do/error" is obviously a Struts action mapping path.

Quoting Mike Jasnowski <mj...@bea.com>:

> It's too bad you couldn't forward that to an Action, which could then
> forward it to a custom page, or rethrow so a Struts exception handler could
> grab it.
> 
> -----Original Message-----
> From: Zhang, Larry (L.) [mailto:lzhang20@ford.com]
> Sent: Tuesday, September 30, 2003 3:13 PM
> To: Struts Users Mailing List
> Subject: configure default error page in web.xml
> 
> 
> HI,
> 
> I have a request to catch a Java Exception in the servlet and display an
> error page. The functionality requires that we display different error
> message for different exception.
> 
> A way to do this is to put try and catch logic in servlet, and if an
> Exception is caught, I do
> request.setAttribute("javax.servlet.jsp.jspExcetion",e), and then forward
> to
> jsp error page, where we check the type of exception implicit object. Based
> on this type, we display different error message. This is fine, but we are
> not going to use this approach.
> 
> The other way is to configure web.xml. We can configure an error page for
> specific Java exception. If the specific exception is raised to the web
> container, the configured error page will get called. My question is that
> is
> there any body  doing this way successfully?
> 
> Thanks.
> 
> Larry Zhang

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


RE: configure default error page in web.xml

Posted by Mike Jasnowski <mj...@bea.com>.
It's too bad you couldn't forward that to an Action, which could then
forward it to a custom page, or rethrow so a Struts exception handler could
grab it.

-----Original Message-----
From: Zhang, Larry (L.) [mailto:lzhang20@ford.com]
Sent: Tuesday, September 30, 2003 3:13 PM
To: Struts Users Mailing List
Subject: configure default error page in web.xml


HI,

I have a request to catch a Java Exception in the servlet and display an
error page. The functionality requires that we display different error
message for different exception.

A way to do this is to put try and catch logic in servlet, and if an
Exception is caught, I do
request.setAttribute("javax.servlet.jsp.jspExcetion",e), and then forward to
jsp error page, where we check the type of exception implicit object. Based
on this type, we display different error message. This is fine, but we are
not going to use this approach.

The other way is to configure web.xml. We can configure an error page for
specific Java exception. If the specific exception is raised to the web
container, the configured error page will get called. My question is that is
there any body  doing this way successfully?

Thanks.

Larry Zhang


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



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