My requirement is to throw user defined exception from servlet with some error code/message. As i have configured this user defined exception type and error jsp in web.xml as
Coming to user defined exception class i have defined as
From my servlet if there is any exception i am throwing MyownException("E001") etc but i am not getting the thrown error message in the jsp.
In error page jsp giving it as
From servlet i am thowing exception as
But when there is an exception the error page is not getting executed and control is going further from the above try catch block and executing the rest code too.
Help me if there is any issue. Also guide me if i am doing anything wrong.
You are throwing your custom exception and also catching it.So the flow is not going to the JSP. Yow will either need to remove the try-catch block or better, just add the exception object in the request scope and forward it to the JSP.
The exception flow should not be going to the JSP nor caught in the servlet. Configure an error handler in the deployment descriptor, log the error, then forward to a JSP that displays a message to the user. The user should never see the exception stack trace, just a customer-appropriate message.