GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Expression Language renders raw text, including HTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Expression Language renders raw text, including HTML" Watch "Expression Language renders raw text, including HTML" New topic
Author

Expression Language renders raw text, including HTML

Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
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..


Thanks & Regards,
Vishal S Shukla (SCJP 93%, SCWCD 94%, SCBCD 100%)
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

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


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
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
Marshal

Joined: Mar 22, 2005
Posts: 42047
    
  64
You can use the "c:out" JSTL tag and its "escapeXml" attribute for this: http://www.ibm.com/developerworks/java/library/j-jstl0318/


Ping & DNS - my free Android networking tools app
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
Its showing "Content Encoding Error" at this url...
Paul Tokmakov
Greenhorn

Joined: Oct 26, 2009
Posts: 3
Try escaping:
<b> </b>
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
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>.
 
GeeCON Prague 2014
 
subject: Expression Language renders raw text, including HTML