views:

155

answers:

2

Hi,

I am using Ciui from google code and all the requests are only GET requests and not POST. The calls are made by the ajax (i am not sure) . I need to know how to read the "searchstring" parameter from this url. When i read this in my servlet using the getQueryString() method i am not able to properly form the actual text. This unicode (when % replaced by /) like text is actually in chinese. Please let me how to decode search string and create the string.

http://xxxx.com?searchString=%u8BF7%u5728%u6B64%u5904%u8F93%u5165%u4EA7%u54C1%u7F16%u53F7%u6216%u540D%u79F0&button=%E6%90%9C%E7%B4%A2

The other parameter is in proper percentage encoding an i am able to decode using the URL decode. Thanks in advance

+1  A: 
public void doGet(HttpServletRequest request, HttpServletResponse response) {
    String searchString = request.getParameter("searchString");
    // process searchString
}

Decoding the parameter is done automatically.

Bozho
No. I was not able to get it !
thndrkiss
what happend? exception? null?
Bozho
Yes. It returned null.
thndrkiss
What does `System.out.println(Collections.list(request.getParameterNames()))` say? Is the `searchString` there? (note that it is case sensitive).
BalusC
+2  A: 

Your encoding scheme for those chinese characters actually violates web standards (namely RFC 3986): the percent sign is a reserved character that may not be used except for the standard percent encoding.

I'd strongly advise you to use the standard encoding scheme (UTF-8 bytes and percent encoding); then you can simply use the standard getParameter() method. If you insist on violating the standard, it may well be impossible to solve your problem within a standards-compliant servlet container.

Michael Borgwardt