• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scriptlet Output

 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<% String s2=request.getParameter("param");
out.println(s2);%> %>
compiles fine and give the output of
%>
but if i write same code as
<% <% String s2=request.getParameter("param");
out.println(s2);%>
the output is
org.apache.jasper.JasperException: Unable to compile class for JSPC:\jakarta-tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fExpression_00031_0002ejspExpression1_jsp_31.java:141: Missing term.
out.write(" \r\n");
^
C:\jakarta-tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fExpression_00031_0002ejspExpression1_jsp_31.java:144: Missing term.
<%
^
2 errors
my question is why the container consider the n nos of %>
at end of scriptlet as acceptable but not even 1
<% before scriptlet as acceptable
can any one Pls clarify
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This is quite simple. When the compiler encounters <% it excepts java code to follow but in case 2 of urs there is <% and naturally gives compilation error. Coming on to case 1 when the compiler encounters %> it concludes that scriptlet is over.. and anything that follows is text unless the next token is <% or directive or jsp actions..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic