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>