About Question enthuware.jwpv6.2.802 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
ETS User

About Question enthuware.jwpv6.2.802 :

Post by ETS User »

Hi,

Could you please clarify why ${exception.message} is not a valid answer for the question. Is is because we don't know for sure if isErrorPage attribute was set to true and so we don 't have implicit variable exception?

If errorPage attribute was false then accordying to your explanation last option (${requestScope["javax.servlet.error.exception"].message}) shouldn't be valid but instead maybe we should have
(${requestScope["javax.servlet.jsp.jspException"].message}). Thanks

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.802 :

Post by admin »

${exception.message} should be a valid answer as well because the question says the page has been invoked as a result of an exception.

This has now been fixed. Thank you for your feedback!

Another ETS user

Re: About Question enthuware.jwpv6.2.802 :

Post by Another ETS user »

Mock Exam Question:

A JSP page myerror.jsp has been invoked as a result of an exception from another JSP page. How can you print the message contained in the exception instead of displaying the whole stack trace in myerror.jsp?

One of the choices highlighted as correct: ${exception.message}

Other correct choices shown:
${pageContext.exception.message}
${requestScope["javax.servlet.error.exception"].message}

The exception object is not an EL implicit object so this should not be a valid choice!?!

Placing the ${exception.message} in a myerror.jsp where <%@page isErrorPage="true"%> that was invoked by some cause_error.jsp where <%@page errorPage="myerror.jsp"%> will not display the error message because exception is null.

Here is the list of the valid implicit objects for EL (JSP implicit objects)
-pageScope
-requestScope
-applicationScope
-sessionScope
-param
-paramValues
-header
-headerValues
-cookie
-initParam
-pageContext

exception is valid when you use it as as <%=exception.toString()%> but not in the EL.

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.802 :

Post by admin »

When a page is an error page, an additional implicit variable exception is also available as specified in Table 1.7 of JSP specification.

HTH,
Paul.

tori3852
Posts: 38
Joined: Wed Oct 31, 2012 2:53 am
Contact:

Re: About Question enthuware.jwpv6.2.802 :

Post by tori3852 »

When a page is an error page, an additional implicit variable exception is also available as specified in Table 1.7 of JSP specification.
I think not – did you mean implicit scripting variable (which is not the same)? Please cite the specification about this variable.

Just tried in Tomcat 7:

Code: Select all

<%@ page isErrorPage="true" %>

<pre>
exception: ${exception}
exception.message: ${exception.message}
pageContext.errorData: ${pageContext.errorData}
pageContext.errorData.throwable: ${pageContext.errorData.throwable}
pageContext.errorData.statusCode: ${pageContext.errorData.statusCode}
pageContext.errorData.requestURI: ${pageContext.errorData.requestURI}
pageContext.errorData.servletName: ${pageContext.errorData.servletName}
requestScope["javax.servlet.error.exception"]: ${requestScope["javax.servlet.error.exception"]}
requestScope["javax.servlet.jsp.jspException"]: ${requestScope["javax.servlet.jsp.jspException"]}
</pre>
exception:
exception.message:
pageContext.errorData: javax.servlet.jsp.ErrorData@36a6efd9
pageContext.errorData.throwable: java.lang.NumberFormatException: empty String
pageContext.errorData.statusCode: 500
pageContext.errorData.requestURI: /normal-web/exception.jsp
pageContext.errorData.servletName: jsp
requestScope["javax.servlet.error.exception"]: java.lang.NumberFormatException: empty String
requestScope["javax.servlet.jsp.jspException"]: java.lang.NumberFormatException: empty String

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.802 :

Post by admin »

You are right. Table 1.7 is for implicit scripting variables. Implicit objects for EL in section 2.4 does not specify this.

this has now been fixed.

thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests