• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

escape sequences

 
Ranch Hand
Posts: 398
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 %>
 
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The same code worked for me too!!
Trupti
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 398
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
</% %>
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic