Yet another one for the FAQ ;-).

An error-page element for a status code of 500 won't be invoked if the
Servlet/JSP throws an exception out of the service method.  For that, you
need to have an error-page element with an exception-type, e.g.:
  <error-page>
     <exception-type>java.lang.Exception</exception-type>
     <location>/Error.jsp</location>
  </error-page>

"Erez Efrati" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> I am using Tomcat/Struts and I am trying to catch errors in JSP pages
> without luck. It only works if I put the <%page errorPage="/MyError.jsp"
> %> tag in the page. I tried to remove it and use the <error-page> in the
> Web.xml but it didn't catch anything. What is wrong here?
>
> The page which causes the exception (A sample file, the version that
> catches and the error redirects to the MyError.page as supposed):
>
> <%@ page contentType="text/html; charset=windows-1255" %>
> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
> <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <%@ page errorPage="MyError.jsp" %>
> <html:html xhtml="true" locale="true">
> <head>
> <title>
> hello
> </title>
> <html:base/>
> </head>
> <body bgcolor="#ffffff">
> <h1>
> JBuilder Generated JSP
> </h1>
> <html:form action="" method="post">
> <br><br>
> <html:submit value="Submit" property="Submit"/>
> <html:reset value="Reset"/>
> </html:form>
> </body>
> </html:html>
>
> ============
> THE WEB.XML
> ============
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
> 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd";>
> <web-app>
>   <servlet>
>     <servlet-name>action</servlet-name>
>
> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
>     <init-param>
>       <param-name>config</param-name>
>       <param-value>/WEB-INF/struts-config.xml</param-value>
>     </init-param>
>     <init-param>
>       <param-name>debug</param-name>
>       <param-value>2</param-value>
>     </init-param>
>     <load-on-startup>2</load-on-startup>
>   </servlet>
>   <servlet>
>     <servlet-name>debugjsp</servlet-name>
>     <description>Added to compile JSPs with debug info</description>
>     <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
>     <init-param>
>       <param-name>classdebuginfo</param-name>
>       <param-value>true</param-value>
>     </init-param>
>     <load-on-startup>3</load-on-startup>
>   </servlet>
>   <servlet-mapping>
>     <servlet-name>action</servlet-name>
>     <url-pattern>*.do</url-pattern>
>   </servlet-mapping>
>   <servlet-mapping>
>     <servlet-name>debugjsp</servlet-name>
>     <url-pattern>*.jsp</url-pattern>
>   </servlet-mapping>
>   <welcome-file-list>
>     <welcome-file>index.jsp</welcome-file>
>   </welcome-file-list>
>
>   <error-page>
>     <error-code>500</error-code>
>     <location>/MyError.jsp</location>
>   </error-page>
>
>   <taglib>
>     <taglib-uri>/tags/struts-bean</taglib-uri>
>     <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>/tags/struts-bean-el</taglib-uri>
>     <taglib-location>/WEB-INF/struts-bean-el.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>/tags/struts-html</taglib-uri>
>     <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>/tags/struts-html-el</taglib-uri>
>     <taglib-location>/WEB-INF/struts-html-el.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>/tags/struts-logic</taglib-uri>
>     <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>/tags/struts-logic-el</taglib-uri>
>     <taglib-location>/WEB-INF/struts-logic-el.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>/tags/struts-nested</taglib-uri>
>     <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>/tags/struts-template</taglib-uri>
>     <taglib-location>/WEB-INF/struts-template.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>/tags/struts-tiles</taglib-uri>
>     <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
>     <taglib-location>/WEB-INF/c.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>http://java.sun.com/jstl/core_rt</taglib-uri>
>     <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
>     <taglib-location>/WEB-INF/fmt.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>http://java.sun.com/jstl/fmt_rt</taglib-uri>
>     <taglib-location>/WEB-INF/fmt-rt.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
>     <taglib-location>/WEB-INF/sql.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>http://java.sun.com/jstl/sql_rt</taglib-uri>
>     <taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>http://java.sun.com/jstl/xml</taglib-uri>
>     <taglib-location>/WEB-INF/x.tld</taglib-location>
>   </taglib>
>   <taglib>
>     <taglib-uri>http://java.sun.com/jstl/xml_rt</taglib-uri>
>     <taglib-location>/WEB-INF/x-rt.tld</taglib-location>
>   </taglib>
> </web-app>
>
>
> Thanks in advance,
> Erez




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

Reply via email to