File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Not recognizing the error-page tag in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Not recognizing the error-page tag in web.xml" Watch "Not recognizing the error-page tag in web.xml" New topic
Author

Not recognizing the error-page tag in web.xml

Sudhir V
Ranch Hand

Joined: Dec 25, 2002
Posts: 143
Hi
I have the following code in the web.xml file
<error-page>
<exception-type>java.sql.SQLException</exception-type>
<location>/servlet/error_handler</location>
</error-page>
and the following is the error_handler servlet
class error_handler extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
ServletContext sud = this.getServletContext ();
res = (HttpServletResponse)sud.getAttribute ("resobj");
SQLException ce = (SQLException)sud.getAttribute ("excp");
String msg = ce.getMessage ()+" in error-handler";
res.sendError (HttpServletResponse.SC_NO_CONTENT ,msg);

}
}
the main program throws an SQLExcpetion but the container is not invoking the error_handler servlet. any suggestions!!!
Thanks
Sudhir


Sudhir V<br />(SCJP 1.2, SCWCD, OCA, SCBCD)
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5370
check the position of <error-page> tag in web.xml.
restart the server.


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
if your code throws an exception (r u sure it does? ) the problem is probably in your error-page tag in the web.xml. read this :
http://developer.java.sun.com/developer/Books/javaserverpages/servlets_javaserver/servlets_javaserver05.pdf
there is also a chance , in case you use ie, your browser uses its own error messages. to stop this uncheck "use friendly error messages" in your ie preferences.


Asher Tarnopolski
SCJP,SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not recognizing the error-page tag in web.xml
 
Similar Threads
Error Handling Question
Unavailable Exception Problem
Page can't displayed - problem of configuring error location with servlet name in DD
Error handling
Something wrong with my application