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
About Question enthuware.jwpv6.2.802 :
Moderators: Site Manager, fjwalraven
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.jwpv6.2.802 :
${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!
This has now been fixed. Thank you for your feedback!
Re: About Question enthuware.jwpv6.2.802 :
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.
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.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.jwpv6.2.802 :
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.
HTH,
Paul.
-
- Posts: 38
- Joined: Wed Oct 31, 2012 2:53 am
- Contact:
Re: About Question enthuware.jwpv6.2.802 :
I think not – did you mean implicit scripting variable (which is not the same)? Please cite the specification about this variable.When a page is an error page, an additional implicit variable exception is also available as specified in Table 1.7 of JSP specification.
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
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.jwpv6.2.802 :
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!
this has now been fixed.
thank you for your feedback!
Who is online
Users browsing this forum: No registered users and 8 guests