Suppose I have a string like '= &? /; # +% 'to be part of my url, let's say this:
example.com/servletPath/someOtherPath/myString/something.html?a=b&c=d
where myString is the line above. I encoded the critical part so that the url looks like
example.com/servletPath/someOtherPath/%3D%26%3F%2F%3B%23%2B%25/something.html?a=b&c=d
So far so good.
When I am in the servlet and I read any of request.getRequestURI() , request.getRequestURL() or request.getPathInfo() , the return value is already decoded, so I get strilng as
someOtherPath/=&?/;
and I cannot distinguish between real special characters and encoded ones.
I solved a specific problem by banning the characters described above altogether, but in this situation I still wonder if there is a way to get an uncoded URL in a servlet class.
GIVE ANOTHER EDITING: When I hit this issue last night, I was too tired to notice what was actually happening, which is even weirder! I have a servlet, say / servletPath / *, after which I can put whatever I want and get the response of my servlet depending on the rest of the path, except when there is% 2F in the path. In this case, the request never hits the servlet, and I get 404! If I put '/' instead of% 2F, it works fine. I am running Tomcat 6.0.14 on Java 1.6.0-04 on Linux.
source share