• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to escape % in JSP

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
If in a jsp file, I just want to display the following line:
This is a test of display <%.
in JSP, I wrote, This is a test of display <\%, I used the escape, why it still shows Server Error?

Thanks a lot.

Hai
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This worked for me.
(IE 6, Tomcat 4.1.03 )

- ortimuS
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Lin

Ortimus is correct. That works for me too. Can you post the code which you used and also the error you get? That would help us understand your problem better.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Lin,

Just now registered in java ranch.

i seen your code.

I got one solution for your problem.

my solutions for your problem

in Example.jsp
---------------

<html>
<body bgcolor="cyan">
<h1>
This is a test of display <%
</h1>
</body>
</html>

when we deploy this jsp in web server we get output like this

This is a test of display <%

Here < is entity ref to < symbol
% is entity ref to % symbol

Thanks
kishore
 
kishore batchu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lin,

my solution to your problem is

in exmple.jsp


<html>
<!--
<body bgcolor="cyan">
<h1>
This is a kishore test of display <%
</h1>
</body>

-->
<!--
here < is a entity refer to <
% is a entity refer to %

-->
</html>

Thank you
kishore batchu
 
Hai Lin
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ortimus,
Thanks a lot. You are right, just using <\% should works, I tested on the Tomcat 5, working fine. The problem I met is the webserver of iplanet6.0, I will test on iplanet6.0 laster.
But another question, how to you display
<%@ include file="test1.jsp" %> to the screen as it is? I mean, how to escape <%@ sign in the jsp? I used <%\@ ... to test, not working.
Waiting for you guys's reply!

Thanks a lot!

Hai
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%\@ include file="test1.jsp" %>
 
Atanas Roussev
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Hai Lin

Even though i wanted to write it properly today i saw i gave you wrong syntax.

Proper is:

<\%@ include file="lepage.jsp" %>
[ May 31, 2004: Message edited by: atanas roussev ]
 
Sumitro Palit
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai,

I have not used iPlanet - but you might try using html escape characters inplace of <, > and see if that helps - even though thats typically a client browser issue.

Also, take a look at the html source generated by each server (Tomcat vs iPlanet) via the browser's View - Source and see if there is any difference that is causing this behavior.

Hope this helps,

- ortimuS
[ June 01, 2004: Message edited by: ortimus tilap ]
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi hai lin,
I think ortimus is right , you could use the following;


hope this helps example helps you.
 
Emman lopez
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry, it actual show the < symbol
what I meant was
< %@ include file="test1.jsp" %>

with the ; after the lt.
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You really should escape the '<' in your HTML text. Once you do that, it's easy


[ June 08, 2004: Message edited by: Michael Zalewski ]
 
Michael Zalewski
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's hard to make this board display what I intended.

But '<' should never be in your web page. It should be '&lt;'. Once you do that, it's easy to make the page say <%, which you code as

 
For my next trick, I'll need the help of a tiny ad ...
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic