• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Manning-JSP-escape sequence

 
Sudd Ghosh
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi -
I am trying some escape sequences from the Manning book, chapter 12, section 12.1.4.
My JSP code mydate.jsp (the part inside the html body) is :
The opening tag of a scriptlet is <\%
The closing tag of a scriptlet is %>
<BR>
<%= "The opening tag of a scriptlet is <%" %>
<%= "The closing tag of a scriptlet is %\>" %>
The relevant portion of the generated servlet mydate_jsp.java from the "tomcat/work.." directory is :
out.write("<BR>\r\n-->\r\nThe opening tag of a scriptlet is ");
out.write("<%\r\nThe closing tag of a scriptlet is %>\r\n");
out.write("<BR>\r\n");
out.print( "The opening tag of a scriptlet is <%" );
out.write("\r\n");
out.print( "The closing tag of a scriptlet is %>" );
out.write("\r\n");
AND the output on running http://localhost:8080/myExamples/jsp/mydate.jsp
is :
The opening tag of a scriptlet is
The opening tag of a scriptlet is
(which is not correct).
I don't know where I'm going wrong with this, but somehow I'm not able to use the backslash escape properly. I have coded it exactly as per the aforementioned section of the Manning book.
Thanks, Sudd
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try t write the '<' tag as '& lt;' (whitout space) - and '>' as '& gt;' (whitout space)
Rene
[ December 25, 2002: Message edited by: Rene Larsen ]
 
Sudd Ghosh
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rene -
What you suggested worked. But I'm still wondering how to use the escape sequences mentioned in Hanumant's book, or is it possible that its use depends upon the container, ie, does Apache tomcat have some problems in interpreting those? Or is it another error in Manning's book?
Thanks
 
bor
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sudd Ghosh:
Hi -
I am trying some escape sequences from the Manning book, chapter 12, section 12.1.4.
My JSP code mydate.jsp (the part inside the html body) is :
The opening tag of a scriptlet is <\%
The closing tag of a scriptlet is %>
<BR>
<%= "The opening tag of a scriptlet is <%" %>
<%= "The closing tag of a scriptlet is %\>" %>
The relevant portion of the generated servlet mydate_jsp.java from the "tomcat/work.." directory is :
out.write("<BR>\r\n-->\r\nThe opening tag of a scriptlet is ");
out.write("<%\r\nThe closing tag of a scriptlet is %>\r\n");
out.write("<BR>\r\n");
out.print( "The opening tag of a scriptlet is <%" );
out.write("\r\n");
out.print( "The closing tag of a scriptlet is %>" );
out.write("\r\n");
AND the output on running http://localhost:8080/myExamples/jsp/mydate.jsp
is :
The opening tag of a scriptlet is
The opening tag of a scriptlet is
(which is not correct).
I don't know where I'm going wrong with this, but somehow I'm not able to use the backslash escape properly. I have coded it exactly as per the aforementioned section of the Manning book.
Thanks, Sudd
 
bor
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Sudd,
Your code is correct. The reason that you see by that view is that <% ... %> will be interpret to be some script in browser. Please view the generated source from your browser. You can save it to mydate.html to understand it more clearly.
Originally posted by Sudd Ghosh:
Hi -
I am trying some escape sequences from the Manning book, chapter 12, section 12.1.4.
My JSP code mydate.jsp (the part inside the html body) is :
The opening tag of a scriptlet is <\%
The closing tag of a scriptlet is %>
<BR>
<%= "The opening tag of a scriptlet is <%" %>
<%= "The closing tag of a scriptlet is %\>" %>
The relevant portion of the generated servlet mydate_jsp.java from the "tomcat/work.." directory is :
out.write("<BR>\r\n-->\r\nThe opening tag of a scriptlet is ");
out.write("<%\r\nThe closing tag of a scriptlet is %>\r\n");
out.write("<BR>\r\n");
out.print( "The opening tag of a scriptlet is <%" );
out.write("\r\n");
out.print( "The closing tag of a scriptlet is %>" );
out.write("\r\n");
AND the output on running http://localhost:8080/myExamples/jsp/mydate.jsp
is :
The opening tag of a scriptlet is
The opening tag of a scriptlet is
(which is not correct).
I don't know where I'm going wrong with this, but somehow I'm not able to use the backslash escape properly. I have coded it exactly as per the aforementioned section of the Manning book.
Thanks, Sudd
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic