URLEncoder.encode not working in netscape for special characters

Hi all,

I have the following code in a jsp.

searchString = request.getParameter("searchString");

java.net.URLEncoder.encode(java.net.URLEncoder.encode(searchString,"UTF-8"),"U TF-8");

this was not working for special character ? It gets converted to ?.

I changed the code as given below:

searchString = request.getParameter("searchString");

searchString = new String(searchString.getBytes("ISO-8859-1"),"UTF-8");

java.net.URLEncoder.encode(java.net.URLEncoder.encode(searchString,"UTF-8"),"U TF-8");

It worked in IE but failed in netscape. I also tried adding these two lines in the beginning of the jsp.

request.setCharacterEncoding("UTF-8");

response.setContentType("text/html; charset=UTF-8");

but it was of no use.

Please suggest a way to make it work in netscape also.

Thanks in advance.

[891 byte] By [tech_nwa] at [2007-11-27 7:48:24]
# 1
In the first place, why do you need to do encoding twice?java.net.URLEncoder.encode(java.net.URLEncoder.encode(searchString,"UTF-8"),"U TF-8");
redfragrancea at 2007-7-12 19:29:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hi,thanks a lot for ur help. pls ignore the mistake . I am not encoding it twice.Pls suggest a way to make it work..thanks..
tech_nwa at 2007-7-12 19:29:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
pls see the corrected code. searchString = request.getParameter("searchString");searchString = new String(searchString.getBytes("ISO-8859-1"),"UTF-8"); java.net.URLEncoder.encode(searchString,"UTF-8");
tech_nwa at 2007-7-12 19:29:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
its very urgent for me.pls reply.thanks!!
tech_nwa at 2007-7-12 19:29:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...