mallikarjun mallikarjun - 10 months ago 96
Java Question

How to get full URL which contains # from HttpServletRequest

In my sample application i am displaying some records, based on # am scrolling down to a particular topic. But to edit that message user has to logon. But while constructing destination url in signin pagebased on request object of servlet am not getting the # in url.

URL looks like www.mydomain:8080/SMP/Account/display/topic#M7

public static String getFullURL(HttpServletRequest request) {
StringBuffer requestURL = request.getRequestURL();//**http://xyz:8080/SMP/Account/display/topic**
String queryString = request.getQueryString();

FYI i have a restriction on setting referer.
Is there any other-way to get full url.

Answer Source

You cannot get the url fragment identifier from the HttpServletRequest as its not actually passed along to the server, it is for the client only.

A quick Google for HttpServletRequest fragment identifier should confirm that, including:

How to get the URL fragment identifier from HttpServletRequest

How to detect Fragment identifiers in Url Mappings?