About Question enthuware.jwpv6.2.1136 :

Moderator: admin

Post Reply
himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

About Question enthuware.jwpv6.2.1136 :

Post 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%>

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1136 :

Post 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");

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

Re: About Question enthuware.jwpv6.2.1136 :

Post 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.
If you like our products and services, please help us by posting your review here.

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

Re: About Question enthuware.jwpv6.2.1136 :

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests