Java – get anchor from URI

I'm writing a JSP / servlet, and I'm trying to get the main part of the URI, for example:

blabla.rdf#mark

How do I get tags from my request? Obviously, request Getparameter() does not work?

Any help is welcome

Solution

This is not possible because the client will not send the "anchor part" to the server

For example, the following is a submission http://example.com/#foobar (recorded with Wireshark) the exact requirements generated by chrome:

GET / HTTP/1.1
Host: example.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/532.3 (KHTML,like Gecko) Chrome/4.0.223.11 Safari/532.3
Cache-Control: max-age=0
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding: gzip,deflate
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
If-None-Match: "b300b4-1b6-4059a80bfd280"
If-Modified-Since: Tue,15 Nov 2005 13:24:10 GMT

See no #foobar So the server application cannot read it

You can do some JavaScript magic, store anchors in cookies or hidden input fields, or any witchcraft you enter However, it is not valid for requests that do not originate from your own site It's easy to do anything you need in the server part of the query string, and only use the task anchored to JavaScript, or use it to navigate in a simple HTML document, but this is 90s;)

The following are important parts of RFC 1808:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>