Reputation: 6181
I am developing a web application using JSP & Servlet (IDE: Eclipse, Database: Oracle10). I am using jqGrid to display records in tabular format.
I am using datatype: "xml"
for jqgrid
.
I have a field in database for storing address
and that field contains special characters like ,
;
&
etc. If any of the Address
from database contains &
then jqgrid
is giving me message response 200 ok, type: parsererror
and no data is shown in the grid , and if i remove the &
from the database then it is not showing me this message and showing the data in grid.
{name:'ADDRESS',index:'ADDRESS', width:80,sortable:true,editable:true}
so my question is that how should I send the data, which contains &
Update1:
I know that some characters are XML reserved characters
like &
<
and >
, but then in that case i have to write loop
for checking address on server side and if that address contains this reserved characters then i have to write them as hexadecimal
, so is there any better way for doing this?
Update2: I am using Servlets. following is my code snippet.
out.print("<cell>" +ADDRESS +"A&BC"+"</cell>");//will show parsererror
out.print("<cell>" +ADDRESS +"A"+"</cell>");//will not show error, and data is diplayed
Thanks in advance...
Upvotes: 0
Views: 629
Reputation: 221997
To place information having XML reserved characters you have to use XML reserved characters <![CDATA[...]]>
(see here and here for example) construct to produce correct XML data.
On the client side you should additionally use autoencode: true
jqGrid option additionally.
Upvotes: 2