Hello everyone, I'm new here and have a question on error handling in
servlet, hope you can help me.
My environment are winme, tomcat4.01,
j2ee 1.3
see the following code fragement:
in servlet ...
//1 throw new UnavailableException ("unava", 2);
//2 throw new ServletException ();
//3 throw new RuntimeException();
throw new FileNotFoundException();
in web.xml ...
<error-page>
<exception-type>javax.servlet.UnavailableException</exception-type>
<location>/errorpage/unavailable.html</location>
</error-page>
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/errorpage/servlet.html</location>
</error-page>
<error-page>
<exception-type>java.io.FileNotFoundException</exception-type>
<location>/errorpage/io.html</location>
</error-page>
<error-page>
<exception-type>java.lang.RuntimeException</exception-type>
<location>/errorpage/runtime.html</location>
</error-page>
these codes compile. But only line 2 and 3 in servlet code work(the respective error page is displayed). For line 1,
tomcat default error page is shown. For line 4, the only content shown are those output by servlet before exception thrown point.
From the previous posts in this forum, someone had the same problem with UnavailableException, but worked fine with java.net.MalformedURLException (subclass of IOException). Does anyone have any idea on this?
Thank for your help.
Regards,
Yuqing
[ January 29, 2002: Message edited by: Yuqing Zhu ]