File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not recognizing the error-page tag in web.xml

 
Sudhir V
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
R K Singh
Ranch Hand
Posts: 5382
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check the position of <error-page> tag in web.xml.
restart the server.
 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic