Rakib Ansary Rakib Ansary - 1 year ago 234
Java Question

What does %5B and %5D in POST requests stand for?

I'm trying to write a Java class to log in to a certain website. The data sent in the POST request to log in is


I'm curious what the
means in the key user login.

How do I encode these data?

Answer Source

As per this answer over here: str='foo%20%5B12%5D' encodes foo [12]:

%20 is space
%5B is '['
and %5D is ']'

This is called percent encoding and is used in encoding special characters in the url parameter values.

EDIT By the way as I was reading the following article, it just occurred to me why so many people make the same search. See the note on the bottom of the page:

Also note that if one wishes to follow the more recent RFC3986 for URL's, making square brackets reserved (for IPv6) and thus not encoded when forming something which could be part of a URL (such as a host), the following may help.

function fixedEncodeURI (str) {
    return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']');

Hopefully this will help people sort out their problems when they stumble upon this question.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download