How can I read the html anchor in a Java servlet?

I need to get all parameters from the request, including what appears after the "#". example: request: http: // myserver / m # q = abc I need my server to get all parameters after "#", how are they, where after "?" How can i do this? 10x, Kobe

+4
source share
3 answers

Anchors or URL fragments, as mentioned in RFC 1738 , are not sent by the client to the server when the resource is requested. The rationale is that the fragment URLs are used to determine the location in the resource, and not for another resource on the server. To determine the location in the resource, the client needs to get the full resource from the server, and this process does not require the transfer of information about the fragment (since this does not mean anything to the server).

If you want to send information through a query string using a URL containing a fragment, you need to make sure that the sequence of requests precedes the fragment of the URL. This may be a mistake in your client code if you create the request yourself. Leave the logic for building the request in the browser if you can afford it.

If you want to send a fragment symbol (#) to the server, you will need to encode it in the query string, otherwise the client (browser) will simply ignore this section of the URL when it sends a request to the server.

Questions Related to SO

+11
source

Keep in mind that bindings are a concept on the client side, so they should not be used on the server side. Clients do not send binding data to the server, so you cannot do this. Better to use receive parameters.

+2
source

You cannot do this. The URI specification says:

A link to a specific part of the document may, including the fragment identifier, look like

http://www.myu.edu/org/admin/people#andy 

, and in this case the line "#andy" is not sent to the server , but is saved by the client and used when the entire object was received.

+1
source

All Articles