title: How to redirect to error page when exception occurs from servlet?
body: <p>I am writing a servlet, in that if any exception occurs i donэt want to display exception/error message on browser, so I will redirect to my customized error page. So I have done like this:</p>
  
  <pre><code>protected void doPost(HttpServletRequest request,
          HttpServletResponse response) throws ServletException, IOException {
  try{
      //Here is all code stuff
  }catch(Exception e){
  
    request.getRequestDispatcher("/ErrorPage.jsp").forward(request, response);
    e1.printStackTrace();
  
  }
  </code></pre>
  
  <p>Is this the correct way, if I am wrong please correct me and if there is any better mechanism please tell me.  </p>