File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP 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\' "?>
It is sorta covered in the JavaRanch Style Guide.
subject: Escaping special character