I don't know if this is off topic, since it might be a server side
problem...
I am trying to send a URL-encoded parameter (it is some encrypted data) via
a HTTP GET.
However it get corrupted! And specifically the encoding symbol %00 gets
translated to byte value 63 instead of 0!
Anyone have a clue why this is?
I am sending the data with a GetMethod like this:
byte data[] = new byte[]{0x01,0x02,0x03,0x10,0x0D,0x00,0x40,0x41};
Vector<NameValuePair> parameters = new Vector<NameValuePair>();
parameters.add(new NameValuePair("interfaceId", "echo"));
parameters.add(new NameValuePair("bin", new String(data, "ISO-8859-1")));
HttpMethod method = new GetMethod(testPath);
method.setQueryString((NameValuePair[])parameters.toArray(new
NameValuePair[0]));
httpClient.executeMethod(method);
And directly when arriving in the servlet I print it out:
void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
if (req.getParameter("bin") != null)
System.err.println("bin=" + URLEncoder.encode(req.getParameter("bin")));
...
Which results in the printout:
bin=%40A%3F%01%02%10
(which is also confirmed by inspecting the binary data)
We have observed the same behaviour in both Jetty and Tomcat, so it is not
server specific.
I know we have done this in other systems succesfully, but I cannot point
out why this doesn't work in this case...
Is there a better way to retreiving binary parameters? maybe get the
un-decoded value?
Haven't found any way...
Best regards,
Kent