File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes URLEncoding Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "URLEncoding Issue" Watch "URLEncoding Issue" New topic
Author

URLEncoding Issue

Sam Kumar
Ranch Hand

Joined: Nov 30, 2001
Posts: 38
Hi,
I am facing one problem related to URLEncoding. In my servlet after retrieving lets say name from database...i am encoding using the URLEnoder class and generate a dynamic HTML but it seems that URLCoding is not working properly. Here is the code snippet:
String testStr = "Test'String'";
testStr = URLEncoder.encode( testStr );
System.out.println("encodedValue: " + testStr);
I verified that endoded value is:
Test%27sString
Now I am generating dynamic HTML with
out.println("<A HREF="javascript:submitForm('" + testStr + "');">Test<A>");
The generated page does not contains the encoded value, because of single quote, this link is not working:
<A HREF="javascript:submitForm('Test'String');">Test</A>
Ideally I shoould see:
<A HREF="javascript:submitForm('Test%27sString');">Test</A>
Thanks in advance!
SK
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

Single quote encoding is %27 not %27s


Please ignore post, I have no idea what I am talking about.
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

Have you tried to printout testStr before you encode it, to ensure that the single quote made it into the string?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Please do not cross post. Continue the conversation here.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLEncoding Issue
 
Similar Threads
URLEncoding Issue
Ajax Problem : passing html:select element in returnstring
Escaping Single Quote (apostrophe )
URLEncoding Issue
Tomcat 6 no parsing request parameters with &amp;