Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get URL label when parsing request URL?

URL can have a label, separated with a "#" sign, coming after the URL parameters. E.g. http://example.com/foo/bar.jsp?p1=v1#test_label

I would expect label to be part of request.getQueryString() and part of request.getRequestURL().toString(). But it doesn't seem to be there.

Is there a way to retrieve the label value from HttpServletRequest on server side?

like image 914
alexei.vidmich Avatar asked May 31 '09 15:05

alexei.vidmich


1 Answers

I think the HTTP spec decided that "anchors" (Is that what they're called? Anyway, the hash sign and the label that comes after) don't get passed to the server, they're just used client-side to scroll the page, or to be used in JavaScript. So there's no way you can get that value, other than having a little script passing it to your server with an Ajax request once the page is loaded, but that's not very convenient.

like image 99
Etienne Perot Avatar answered Oct 20 '22 02:10

Etienne Perot