views:

161

answers:

1

i am getting adding some of parameter in query string.value of these param can be "a%%","%" etc.on java code side .while parsing query parameter i m getting char conversionexception as shown below in exception log.

13:14:39,555 ERROR [STDERR] java.io.CharConversionException: EOF 13:14:39,555 ERROR [STDERR] at org.apache.tomcat.util.buf.UDecoder.convert(UDecoder.java:119) 13:14:39,555 ERROR [STDERR] at org.apache.tomcat.util.buf.UDecoder.convert(UDecoder.java:87) 13:14:39,555 ERROR [STDERR] at org.apache.tomcat.util.http.Parameters.processParameters(Paramete rs.java:428) 13:14:39,555 ERROR [STDERR] at org.apache.tomcat.util.http.Parameters.processParameters(Paramete rs.java:515) 13:14:39,555 ERROR [STDERR] at org.apache.tomcat.util.http.Parameters.handleQueryParameters(Para meters.java:298) :14:39,555 ERROR [STDERR] at org.apache.coyote.tomcat4.CoyoteRequest.parseRequestParameters(Co yoteRequest.java:1933)

what should i do?

+3  A: 

It sounds like the query string being sent to your Java code is malformed. The percent sign is special in query strings: It introduces a two-digit hexadecimal number identifying a character. For instance, %20 is a space. To put a percent sign in a query string correctly, one uses %25 (character 25h is the percent sign in Unicode). If the query string you're processing really, literally has %% in it, then it is malformed and you'll want to have the side sending it fixed.

Edit: In your comment you say you're the one sending the invalid query string. To properly encode a query parameter, use the encodeURIComponent JavaScript function:

var encodedValue;
encodedValue = encodeURIComponent(yourTextfield.value);
someurl = "http://example.com?x=" + encodedValue;
T.J. Crowder
actually i am getting value of query parameter from a input textbox (searchinput).i am appending value of this textbox to query string by using jaavscript.so i need to have some way out to send value of this textbox even if it is "%".
Maddy.Shik