Explain how JSP handle run-time exceptions

Explain how JSP handle run-time exceptions?

The errorPage attribute of the page directive can be used to redirects the browser to an error processing page, when uncaught exception is encountered.

For example:
<%@ page errorPage="error.jsp" %>
redirects the browser to the JSP page error.jsp if an uncaught exception is encountered during the request processing.

In error.jsp, if it’s indicated that it’s an error-processing page by <%@ page isErrorPage="true" %> directive, then throwable object describing the exception may be accessed within the error page via the exception implicit object.

How do you restrict page errors display in the JSP page?

a. Set "Errorpage" attribute of PAGE directory to the name of the error page (i.e Errorpage="error.jsp") in your jsp page.

b. In the error.jsp page, set "isErrorpage=TRUE".

Thus the occurrence of an error in the jsp page will automatically call the error page.

Explain how to implement a thread-safe JSP page
JSP Thread - JSPs can be made thread-safe by having them implement the SingleThreadModel interface...
JSP implicit objects - Define implicit objects.
JSP implicit objects - These are the objects that are available for the use in JSP documents. You don’t need to declare them.....
Difference between forward and sendRedirect
A forward is server side redirect while sendRedirect is client side redirect..
Post your comment