How to redirect to error page in servlet?

前端 未结 3 1412
挽巷
挽巷 2021-01-20 13:39

I am writing the servlet , in case of exception I am redirecting to my customized error page for that i have done like this.

In web.xml



        
3条回答
  •  面向向阳花
    2021-01-20 14:14

    You have handled the Exception in your doPost() using ,

    try{
           //Here is all code stuff
           Throw new Exception();
    }catch(Exception e){
             e1.printStackTrace();    
    }
    

    try and catch blocks. so the errorPage.jsp will not be invoked. is invoked for unhandled exceptions

    A nice example tutorial Exception Handling

    Read for more info Best practice error handling in JSP Servlets

提交回复
热议问题