aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes <c:out> and <, >, &"" title="" /> 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 "<c:out> and "<, >, &"" Watch "<c:out> and "<, >, &"" New topic
Author

<c:out> and "<, >, &"

Tyler Wright
Ranch Hand

Joined: Jun 25, 2009
Posts: 40
Hi Folks,

For question 1 on page 378 of Charles Lyon's "SCWCD Study Companion":

The answer is given as C...

Note: I had to put the entityReferences as &_amp; and &_lt; inorder not to have them translated into '&' and '<'
*************************************************
When I ran this in tomcat 5.5.x.x I got:
'Facts & Figures: 5 < 6'

If you try this at home remember to include the taglib directive:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


Am I missing something?

Tyler...


SCJP SCJD
Pawan Arora
Ranch Hand

Joined: Sep 14, 2008
Posts: 105
The value of escapeXml attribute in <cut> tag defaults to 'true'. So you'll get display any XML entities, which is not rendered.
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Tyler. The container sends the response in the form of "Facts &_amp; Figures: 5 &_lt; 6". The browser sees the character entity codes & < and it places the equivalent characters like & <. If you see the page source it will be clear.
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
I think, Javaranch is not using cut , thats why i used &_amp and &_lt, actually there is no _. Sorry for duplicate message. Thankyou.
Tyler Wright
Ranch Hand

Joined: Jun 25, 2009
Posts: 40
Hi all,

Thanks for the quick response...I coded this up based upon your responses:


Which produced this in the browser:
In the browser:
**********************
this is cut escapeXml="false" :
& %amp;

this is a test

this is cut escapeXml="true" :
& %amp; <p> <html><table><th>this is a test</th></table></html>

***************************

But, the view source produced:
<p>
this is cut escapeXml="false" :<br>
& %amp; <p> <html><table><th>this is a test</th></table></html>
</p>

<p>
this is cut escapeXml="true" :<br>
& %amp; <p> <html><table><th>this is a test</th></table></html>
</p>
*****************************************************
My confusion with this came from the browser's presentation; I forgot about the source....

Thanks for clarifying this...it was really bugging me.

PS: To see what is really going on here, the jsp code should be executed and the results viewed your browser and the source viewed with your view source...in this post the entityReferences are automatically translated to their HTML presentations so the effect is lost.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <c:out> and "<, >, &"