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 ?
The Method request. getRequestURI() returns URI with context path. For example, if the base URL of an application is http://localhost:8080/myapp/ (i.e. the context path is myapp), and I call request. getRequestURI() for http://localhost:8080/myapp/secure/users , it will return /myapp/secure/users .
The HttpServletRequest interface provides the getCookies method to obtain an array of cookies that are present in the request. This method returns null if no cookies were sent. The cookies are data sent from the client to the server on every request that the client makes.
ServletRequest provides basic setter and getter methods for requesting a Servlet, but it doesn't specify how to communicate. HttpServletRequest extends the Interface with getters for HTTP-communication (which is of course the most common way for communicating since Servlets mostly generate HTML).
getMethod. Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
"The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the server." Wikipedia about the Frament Identifiert
For further reference see the RFC 2394 Section 4.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With