Re: How to specify an Error Page in a servlet

John Arockiaraj <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
Hi,

Any of the following ways would help you to handle your errors/exceptions:

1. Using <error-page> element in your web.xml, you can specify
which JSP/Servlet should handle what exception(s)/error code(s).

Web Container would pass the following (among 5 request attributes) to your
handler :
        i) javax.servlet.error.status_code
        ii)javax.servlet.error.exception

Note 1: You should not catch those exceptions mentioned in
<error-page></error-page>
          Those exceptions are supposed to be handled and redirected by the
container
          to the error page resource(jsp/servlet) defined in the deployment
descriptor

Note 2:
FYR:
http://archive.moreservlets.com/Web-App-Code/deployDemo/WEB-INF/web.xml

2. RequestDispatcher.forward(...)
        - You can pass the exception/error code as request attribute to the
handler(servlet/jsp)

3. HttpResponse.sendRedirect(...)

HTH
John

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[email protected]]On Behalf Of
Emmanuel Eze
Sent: Wednesday, June 25, 2003 10:35 PM
To: [email protected]
Subject: How to specify an Error Page in a servlet


Hi all,

Can someone please tell me how to specify an Error Page in a servlet similar
to JSP's errorPage attribute of the page tag.

<%@ page language="java" buffer="8kb" autoFlush="true" isThreadSafe="true"
isErrorPage="false" errorPage="ErrorPage.jsp" %>.


Thanks

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.