How do I create a custom Exception and handle it in web.xml with the error-page tag direct it to a specific page.
I have tried to create a exception extends the servlet exception like this.
public class MyException extends ServletException {
private static final long serialVersionUID = 1L;
private String[] errArray;
public MyException (String[] errArray){
this.errArray = errArray;
}
public String[] getErrors(){
return errArray;
}
}
Then I put this inside web.xml
<error-page>
<exception-type>my pach to the exception.MyException </exception-type>
<location>/web_service_errorr.jsp</location>
</error-page>
And I tried to throw this in the project. Then the exception still we be catch by
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/system_error.jsp</location>
</error-page>
At the beginning of the error message it is javax.servlet.ServletException, but it has something like Root cause my MyException in the message.
If am not doing it right, how should I catch a custom exception and redirect it to a jsp page?