• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

escape sequences

 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a question about escape sequences. If I want "<%" to be printed as is in the output I have to "escape" the special character with a backslash like ( <\%) which is fine. I am able to print the following

This is the beginning of a scriptlet : <\%

without any problem.
And as the parser looks for only opening scriptlet first, the closing scriptlet of %> is fine. I am able to print the following
This is the closing of a scriptlet : %> , no problems.
The problem is when I try the following :


Opening of a scriptlet is <\% and closing is %>.

It doesn't print out anything after the first < character and prints just

opening of a scriptlet is

Does someone have an idea why it ignores the text between an opening an dclosing scriptlet characters even though they are escaped?

Thanks,
vasu
 
kavitha yalamanchili
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had this as my test.jsp
<html><body>
Opening of a scriptlet is <\% and closing is %>
</body></html>
It worked fine..
I got the output as
Opening of a scriptlet is <% and closing is %>
 
trupti nigam
Ranch Hand
Posts: 627
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same code worked for me too!!
Trupti
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,if u want to escape anything you can do it by adding the backslash character \ .See the specs for details.
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what I did.

<%@ page info = " Opening and closing of scriptlets are <\%, %> " %>
<%= getServletInfo() %>
and this is what I got ....

Opening and closing of scriptlets are <\%, %> .
Please notice the backslash in the output. What am I doing wrong?
Thanks,
vasu
 
kavitha yalamanchili
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Opening and closing of scriptlets are <%, %>
this was the output I got. Looks fine to me..
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi once u open a <% the JSP engine looks for a closing %> So in ur code instead of escaping <% try to escape %> & ur output will be correct.
this:
<% %/>
not this:
</% %>
 
Maha Annadurai
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have saved just the following line in a file called 'test.jsp' and tried to call it through IE6.0 and Netscape 4.08.
test.jsp
--------
Opening of a scriptlet is <\% and closing is %>.

Netscape displays it correctly , but IE displays just this string "Opening of a scriptlet".
Out of curiosity, I did a view-source on the page from IE, and it looks like the source content of the page is right, and it's just IE not displaying it right.
-Maha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic