wood burning stoves*
The moose likes JSP and the fly likes Escaping special character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Escaping special character" Watch "Escaping special character" New topic

Escaping special character

Amarjyoti Das

Joined: Mar 18, 2002
Posts: 16
I am trying to do create a simple String Buffer and my jsp page is failing. Here is what I am trying to do.
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?> ;
When I do <%= sb.toString() %> it returns nothing. If I do \< then I get invalid escape character error message. How can I fix the situation. I need to create an XML page from my JSP page.
Thank you
-- amar
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Did you set the content type of the page to be text/xml?
[ August 28, 2002: Message edited by: Chris Mathews ]
Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
Why can't use a single-quote (') instead of the double-quote (") ? Single-quote does'nt need escaping
Ruilin Yang
Ranch Hand

Joined: Jan 06, 2002
Posts: 150
I would change it as:
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\'1.0\'encoding=\'UTF-8\' "?>
I agree. Here's the link: http://aspose.com/file-tools
subject: Escaping special character
Similar Threads
combining JavaScript and XSL
Struts with parsers
JSPs as XML documents, but no HTML rendered!
Can Jsp be converted into String
Passing multiple listbox to bean using JSP