Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes Printing & Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply 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 agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Printing &amp;
 
Similar Threads
parsing data and storing in the xml
file downloading concept
Displaytag checkbox using struts2
retreaving the value in servlet which is set in session in a jsp page
Implementing HttpSession in the Spring MVC