How to get the request url from HttpServletRequest

Posted by Gagan on Stack Overflow See other posts from Stack Overflow or by Gagan
Published on 2010-05-18T20:05:25Z Indexed on 2010/05/18 20:10 UTC
Read the original article Hit count: 280

Filed under:

Say i make a get request like this:

GET http://cotnet.diggstatic.com:6000/js/loader/443/JS_Libraries,jquery|Class|analytics|lightbox|label|jquery-dom|jquery-cookie?q=hello#frag HTTP/1.0
Host: cotnet.diggstatic.com:6000

My servlet takes request like this: HttpServletRequest req;

When i debug my server and execute, i get the following:

req.getRequestURL().toString() = "http://cotnet.diggstatic.com:6000/js/loader/443/JS_Libraries,jquery%7cClass%7canalytics%7clightbox%7clabel%7cjquery-dom%7cjquery-cookie"
req.getRequestURI() = "/js/loader/443/JS_Libraries,jquery%7cClass%7canalytics%7clightbox%7clabel%7cjquery-dom%7cjquery-cookie"
req.getQueryString() = "q=hello"

How does one get the fragment information ? Also, when i debug the request, i see a uri_ field of type java.net.URI which has the fragment information. This is exactly what i want. How can i get that ?

© Stack Overflow or respective owner

Related posts about httpservletrequest