Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to escape % in JSP

 
Hai Lin
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Sumitro Palit
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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

- ortimuS
 
Balamurugan Muthiah
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
kishore batchu
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Atanas Roussev
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%\@ include file="test1.jsp" %>
 
Atanas Roussev
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Emman lopez
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, it actual show the < symbol
what I meant was
< %@ include file="test1.jsp" %>

with the ; after the lt.
 
Michael Zalewski
Ranch Hand
Posts: 168
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic