About Question enthuware.jwpv6.2.739 :
Posted: Sat May 14, 2016 7:47 pm
For the 4th option, "catch the exception, wrap into ServletException and define the ServletException to error-page mapping in web.xml.
This can be done, even though it is not the best way to handle exception.
This can be done, even though it is not the best way to handle exception.
Code: Select all
@WebServlet("/errorServlet")
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
try{
throw new NotEnoughFundException();
}
catch (NotEnoughFundException e){
throw new ServletException (e);
}
}
}
Code: Select all
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/errorPage.jsp</location>
</error-page>