title: Java Reading Undecoded URL from Servlet
body: <p>Let's presume that I have string like '=&amp;?/;#+%' to be a part of my URL, let's say like this:</p>
  
  <pre><code>example.com/servletPath/someOtherPath/myString/something.html?a=b&amp;c=d#asdf
  </code></pre>
  
  <p>where myString is the above string. I've encoded critical part so URL looks like</p>
  
  <pre><code>example.com/servletPath/someOtherPath/%3D%26%3F%2F%3B%23%2B%25/something.html?a=b&amp;c=d#asdf
  </code></pre>
  
  <p>So far so good. </p>
  
  <p>When I'm in the servlet and I read any of <code>request.getRequestURI()</code>, <code>request.getRequestURL()</code> or <code>request.getPathInfo()</code>, returned value is already decoded, so I get strilng like</p>
  
  <pre><code>someOtherPath/=&amp;?/;#+%/something.html?a=b&amp;c=d#asdf
  </code></pre>
  
  <p>and I can't differentiate between real special characters and encoded ones. </p>
  
  <p>I've solved particular problem by banning above chars altogether, which works in this situation, but I still wonder is there any way to get undecoded URL in servlet class.</p>
  
  <p>YET ANOTHER EDIT: When I've hit this problem last evening I was too tired to notice what is really going on, which is <em>even more bizarre!</em> I have servlet mapped on, say /servletPath/* after that I can put whatever I want and get my servlet responding depending on the rest of a path, <strong>except</strong> when there is %2F in the path. In that case <em>request never hits the servlet</em>, and I get 404! If i put '/' instead of %2F it works OK. I'm running Tomcat 6.0.14 on Java 1.6.0-04 on Linux.</p>