Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Encoding problem in jsp  RSS feed

 
Naresh Talluri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks
I have a problem in jsp while encoding, in my jsp iam using Ajax response as xml, from DTO object iam trying to populate data in jsp ,
but when i found special characters like <,> it is throwing error like not able to parse the data for <,>,
can you please let me know what are the possibilities to overcome this issue.
thanks in advance

Thanks
Naresh
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15861
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does data in the XML contain characters such as < and >?

If that is the case, then your XML is not valid. To solve this, you should either put the data in a CDATA-segment, or escape the < and > with character entity references when you generate the XML:

<element><![CDATA[Some < text]]></element>

or:

<element>Some &lt; text</element>

For more info: XML CDATA, XML and HTML character entity references
[ April 22, 2008: Message edited by: Jesper Young ]
 
Naresh Talluri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
thanks for your idea , but i have one concern..
if i use CDATA in any special characters it is not parsing, fine...
but while parsing iam considering this data and iam not able to populate in
jsp , it is showing empty string,
code :


[ April 22, 2008: Message edited by: Naresh Talluri ]
[ April 22, 2008: Message edited by: Naresh Talluri ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!