Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Escaping special character

 
Amarjyoti Das
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why can't use a single-quote (') instead of the double-quote (") ? Single-quote does'nt need escaping
 
Ruilin Yang
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would change it as:
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\'1.0\'encoding=\'UTF-8\' "?>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic