RSS

Single quote is converting to some special characters

22 Mar

Hi folks,

Recently i have faced one special character issue in JSP and got fixed, sharing with you all. Here is the post.

Requirement : Storing the JSP page fields like Name, Address and Email values in the Page1 and passing all these values to the next Page2. I have to send all these param values to the other system to display all these values in their system.

Issue : When passing these field values with single quote (like Name is Tes’t and Email is Tes’t@test.com), single quote is converting to some special characters
(') when sending the values from Page1 to Page2. due to this it is faling to hit the other system.

Solution:

I have added escapeXml=”false” in the JSP JSTL <c:out> tag.

escapeXml=”false” : The attribute value which is a must attribute and escapeXml attribute which takes a boolean value and is used to check whether there is any need to convert the &, <, > etc to their character encoding codes.

sample code here
var name = “<c:out value=”${bean.name}” escapeXml=”false”/>”;
 var emailId = “<c:out value=”${bean.emailId}” escapeXml=”false”/>”;

After making this modification, it is working as expected (Name is Tes’t and Email is Tes’t@test.com).

My Intension is sharing this issue is to reduce the developers time who has facing the same issue.

Look here for sample code:

http://www.roseindia.net/jsp/simple-jsp-example/JSTLOutWithTagEscaping.shtml

Happy Coding!!.

Get glued to know more updates.

Have a nice day 🙂

Advertisements
 
Leave a comment

Posted by on March 22, 2013 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: