1Z0-900 · Question #53
Which code snippet indicates that the page you are designing is capable of handling errors?
The correct answer is C. <%@page isErrorPage="true"%>. Option C (<%@page isErrorPage="true"%>) is correct because this JSP page directive explicitly declares the current page as an error-handling page. This designation activates the implicit exception object, giving the page access to the Throwable that caused the error - which is…
Question
Which code snippet indicates that the page you are designing is capable of handling errors?
Options
- A<%@page errorPage="errorHandler.jsp"%>
- B<%= requestScope['javax.servlet.error'] !=null %>
- C<%@page isErrorPage="true"%>
- D<c:set var="errorHandler" value="true"/>
How the community answered
(66 responses)- A2% (1)
- B5% (3)
- C92% (61)
- D2% (1)
Explanation
Option C (<%@page isErrorPage="true"%>) is correct because this JSP page directive explicitly declares the current page as an error-handling page. This designation activates the implicit exception object, giving the page access to the Throwable that caused the error - which is required to actually process and display error information.
Option A is the inverse: errorPage="errorHandler.jsp" tells the container to forward errors to another page, so it marks the current page as a client of error handling, not the handler itself.
Option B is invalid JSP/EL syntax and would render as a string literal rather than execute logic; even if corrected, checking for an error attribute in request scope doesn't declare the page as an error handler.
Option D simply sets a custom scoped variable with no semantic meaning to the JSP container - the container ignores user-defined variables when deciding how to route errors.
Memory tip: Focus on the prefix - isErrorPage ("I am the error page") vs. errorPage ("send errors to that page"). The is keyword is the self-declaration; without it, you're just pointing elsewhere.
Topics
Community Discussion
No community discussion yet for this question.