Page 1 of 1
About Question enthuware.jwpv6.2.1136 :
Posted: Tue Apr 12, 2016 10:45 pm
by himaiMinh
FYI, I tried to run this code.
I got this error:
Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 8 in the jsp file: /index.jsp
sb cannot be resolved to a variable
5: <jsp:useBean id = "sb" class="java.lang.StringBuffer" />
6: sb.append("Hello");
7: <%}%>
8: <%=sb%>
Re: About Question enthuware.jwpv6.2.1136 :
Posted: Tue Apr 12, 2016 10:48 pm
by himaiMinh
If I remove <%=sb%>
Code: Select all
<% { %>
<jsp:useBean id = "sb" class="java.lang.StringBuffer" />
sb.append("Hello");
<%}%>
It prints out
"sb.append("Hello");
Re: About Question enthuware.jwpv6.2.1136 :
Posted: Tue Apr 12, 2016 10:50 pm
by admin
himaiMinh wrote:FYI, I tried to run this code.
I got this error:
Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 8 in the jsp file: /index.jsp
sb cannot be resolved to a variable
5: <jsp:useBean id = "sb" class="java.lang.StringBuffer" />
6: sb.append("Hello");
7: <%}%>
8: <%=sb%>
Looks like the exact words in the error message have changed between the versions of tomcat but the meaning is the same. sb is undefined or cannot be resolved.
-Paul.
Re: About Question enthuware.jwpv6.2.1136 :
Posted: Tue Apr 12, 2016 10:52 pm
by admin
himaiMinh wrote:If I remove <%=sb%>
Code: Select all
<% { %>
<jsp:useBean id = "sb" class="java.lang.StringBuffer" />
sb.append("Hello");
<%}%>
It prints out
"sb.append("Hello");
Yes, this is to be expected as per given the explanation.