JSP Error Pages and Servlets
nYou can forward a Servlet exception on to your JSP error page too.
nFor example, the following code generates an exception and forwards it to ErrPage.jsp in the event that no password was passed into the Servlet (presumably from an HTML form).
n
String password = request.getParameter("password");
if (password == null)
  request.setAttribute("javax.servlet.jsp.jspException",
  new Exception("missing password"));
RequestDispatcher dispatcher =
      getServletContext().getRequestDispatcher("/ErrPage.jsp");
dispatcher.forward(request, response);