Handling Servlet Exceptions (using RequestDispatcher)
In this we have to just write the RequestDispatcher code in the catch block.
public void service (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
//some code which throws exception
} catch (Exception e) {
RequestDispatcher dispatcher = getServletContext.getRequestDispatcher("/error.jsp");
dispatcher.forward(request, reponse);
}
}
0 Comments:
Post a Comment
<< Home