This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSP and the fly likes Printing & Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Printing &" Watch "Printing &" New topic
Author

Printing &

Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
Can anyone tell me how to print the '&' (or & on a JSP page from a XML stream? Sorry I don't have access to the code right now but what I think they did was pull the string as text then marked it up in XML then used xslt to transform it on the JSP page and display it to print. Everything looks okay except they couldn't come up with a way to escape the '&' char. I've been looking on xml sites but can't seem to find this.
Carl P.
Praveen Kumar Jha
Greenhorn

Joined: Jul 27, 2002
Posts: 10
In XML stream, you can wrap the text with CDATA.
e.g. <!CDATA[yourdata&andwhatever]]


Praveen Kumar<br />Sun Certified Programmer for Java 2 Platform
Shawn Bayern
Author
Ranch Hand

Joined: May 06, 2002
Posts: 160
Originally posted by Carl Parrish:
Can anyone tell me how to print the '&' (or & on a JSP page from a XML stream? Sorry I don't have access to the code right now but what I think they did was pull the string as text then marked it up in XML then used xslt to transform it on the JSP page and display it to print. Everything looks okay except they couldn't come up with a way to escape the '&' char. I've been looking on xml sites but can't seem to find this.
Carl P.

Unless I'm misunderstanding, you can 'escape' & as &. If you're printing out XML from a JSP page, you can use the <c ut> and <x ut> tags of JSTL (the JSP Standard Tag Library), which by default automatically escape XML metacharacters like '&' for you.


Shawn Bayern<br />"JSTL in Action" <a href="http://www.jstlbook.com" target="_blank" rel="nofollow">http://www.jstlbook.com</a>
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Printing &amp;
 
jQuery in Action, 3rd edition