This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Expression Language renders raw text, including HTML

 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Helloz,

When using expression value in jsp, if expression includes HTML tags, tags are rendered by container. Say, I have attribute "currentTip" in the session and it contains value " tag make things bolder." (Head First Servlets & Jsp book 2nd edition, pg 283). And when we print it in jsp, by saying .

It shows " tag make things bolder." I could not find solution for how we can avoid this.



Please help..
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the software ate up some of your post where you are trying to show us the 'b' HTML tags ?

Did you try this



I doubt if I have fully understood your question, but I thought I would reply anyway
 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The issue I am asking for just happend in my first post... Now I don't know how can I explain the problem..

Let me try...

I have one session variable, say "currentTip" and

Now I want to print this in JSP, by saying ${currentTip}. It should be printed without rendering that "b" tags. ie. I want to disable HTML rendering for value of expression. how can I do that?
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the "c:out" JSTL tag and its "escapeXml" attribute for this: http://www.ibm.com/developerworks/java/library/j-jstl0318/
 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its showing "Content Encoding Error" at this url...
 
Paul Tokmakov
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try escaping:
<b> </b>
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vish Shukla wrote:Its showing "Content Encoding Error" at this url...


Did you use c:out or not?? Did you use a taglib directive for the c:out tag?? Show us the complete stack trace of the error...
 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think there is a big misunderstanding... sorry for my laziness.. Actually "Content Encoding Error" is shown not for <c:out> but said that for Ulf Dittmer's post.

You can use the "c:out" JSTL tag and its "escapeXml" attribute for this: http://www.ibm.com/developerworks/java/library/j-jstl0318/


I am yet to try <c:out>.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic