Hi All,

I am facing an issue with apostrophe.
Please look in to my code

String ss1="St: Mary's School.";
out.println("<input type='text' name='shipTest' value='"+ ss1 +"'>");

Output: St: Mary
Not able to display letters after the apostrophe. Kindly help me to resolve this issue.

Thanks in advance
--
Vinith

Try an escape character like "\" as in String ss1="St: Mary\'s School.";

Hi Henzard,

Thanks a lot for your reply.

I tried but its not coming properly. Then i tried replaceAll Method.

String s="St: Mary's School.";
String rp = "&nbsp;";
String s1=s.replaceAll(" ",rp);
out.println("<form action='replaceFunctionDisplay.jsp' method='post'>");
out.println("<input type='text' name='ship' value="+ s1 +">");
out.println("<input type='submit'>");
out.println("</form>");

Now i getting proper output inside my text box.
When i am paasing this text box value to another page i am getting the output with special characters instead of &nbsp;

<%
    String str = request.getParameter("ship");
    out.println("String : "+str);
    System.out.println("String : "+str);
%>

Out put : St: Mary's School.

Kindly help me

Try :

String s="St: Mary's School.";
String rp = "\'";
String s1=s.replaceAll("'",rp);
out.println("<form action='replaceFunctionDisplay.jsp' method='post'>");
out.println("<input type='text' name='ship' value="+ s1 +">");
out.println("<input type='submit'>");
out.println("</form>");

Hi Henzard,

Thanks for the quick response
Its look better.
Got this output inside the text box : St: Mary s School. //Apostrophe is not displaying
Got this output on next page: St: Mary s School. // Special character  displaying instead of apostrophe

String rp = "&apos;";

Hi Henzard,

Thanks for the reply.
&apos; not working. I tried with

String rps = "&#39 ;";

Now its working fine. Getting both outputs correctly.

Thanks a lot for the help...

&#39

This &#39 works in the Hybris impex file.
Thanks A Ton
Manoj Phutela

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.