Valid 1Z0-899 Dumps shared by ExamDiscuss.com for Helping Passing 1Z0-899 Exam! ExamDiscuss.com now offer the newest 1Z0-899 exam dumps, the ExamDiscuss.com 1Z0-899 exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com 1Z0-899 dumps with Test Engine here:
You are working on a JSP that is intended to inform users about critical errors in the system. The JSP code is attempting to access the exception that represents the cause of the problem, but your IDE is telling you that the variable does not exist. What should you do to address this problem?
Correct Answer: A
Explanation/Reference: Exception is a JSP implicit variable The exception variable contains any Exception thrown on the previous JSP page with an errorPage directive that forwards to a page with an isErrorPage directive. Example: If you had a JSP (index.jsp) which throws an exception (I have deliberately thrown a NumberFormatException by parsing a String, obviously you wouldn't write a page that does this, its just an example) <%@ page errorPage="error.jsp" %> <% Integer.parseInt("foo"); //throws an exception %> This will forward to error.jsp, If error.jsp was <%@ page isErrorPage = "true"%> <body> <h2>Your application has generated an error</h2> <h3>Please check for the error given below</h3> <b>Exception:</b><br> <font color="red"><%= exception.toString() %></font> </body> Because it has the <%@ page isErrorPage = "true"%> page directive, the implicit variable exception will contain the Exception thrown in the previous jsp So when you request index.jsp, the Exception will be thrown, and forwarded to error.jsp which will output html like this <body> <h2>Your application has generated an error</h2> <h3>Please check for the error given below</h3> <b>Exception:</b><br> <font color="red">java.lang.NumberFormatException: For input string: "foo"</font> </body> As @JB Nizet mentions exception is an instanceof Throwable calling exception.getMessage() For input string: "foo" instead of java.lang.NumberFormatException: For input string: "foo"