Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes tag error-page web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "tag error-page web.xml" Watch "tag error-page web.xml" New topic
Author

tag error-page web.xml

Isaias C. Barroso
Ranch Hand

Joined: Jan 22, 2002
Posts: 165
Hi all,
I would like that my <error-page> was a Servlet, but don't work with Tomcat 4.1
I have a web deployment file with this:
<servlet>
<servlet-name>ErrorPageServlet</servlet-name>
<servlet-class>ErrorPageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ErrorPageServlet</servlet-name>
<url-pattern>/Error</url-pattern>
</servlet-mapping>

<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/Error</location>
</error-page>
If i enter on browser : http://localhost:8080/cert/Error this work fine.
But if occur any Exception, the page that is show is a default error page of Tomcat.
If i change a location for a jsp page work fine too.
How to work with servlet not .jsp?
Thanks


Isaias
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
try to set in your <location> a direct root related path to your error-servlet, not a mapped url-pattern.
does it help?


Asher Tarnopolski
SCJP,SCWCD
Isaias C. Barroso
Ranch Hand

Joined: Jan 22, 2002
Posts: 165
Thanks Asher,
But this don't function too...
I will go try others possibilities.
Best Regards,
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
hmm. did you type the full version of your web.xml file? may be there is a tags' order problem in your web deployment descriptor?
Isaias C. Barroso
Ranch Hand

Joined: Jan 22, 2002
Posts: 165
Hi,
Follow the web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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>Teste</servlet-name>
<servlet-class>Teste</servlet-class>
</servlet>
<servlet>
<servlet-name>setStatusCode</servlet-name>
<servlet-class>SetStatusCodeServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>sendErrorServlet</servlet-name>
<servlet-class>SendErrorServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>SomaValores</servlet-name>
<servlet-class>SomaValores</servlet-class>
</servlet>
<servlet>
<servlet-name>ErrorPageServlet</servlet-name>
<servlet-class>ErrorPageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ErrorPageServlet</servlet-name>
<url-pattern>/Erro</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/jsp/erro.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/cert/servlet/ErrorPageServlet</location>
</error-page>
</web-app>
Thanks
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
in <servlet> you write
<servlet-class>ErrorPageServlet</servlet-class>
but in <error-page> you have
<location>/cert/servlet/ErrorPageServlet</location>
the location of ErrorPageServlet in these cases is not the same.
Isaias C. Barroso
Ranch Hand

Joined: Jan 22, 2002
Posts: 165
Thanks Asher,
Best Regards
 
wood burning stoves
 
subject: tag error-page web.xml
 
Similar Threads
servlet-mapping tag of deployment descriptor
getting 404 error
response.sendRedirect problem
Page can't displayed - problem of configuring error location with servlet name in DD
SERVLET MAP