URL has # included; want to send the url including # to the server

I have my Servlet code in application A and I need to send a url to application B, which validates my credentials and returns me to the url which I gave firstly(single sign on authentication is happening here).

Now, when i am giving url which includes # in it. (let suppose for ex: http://google.com/DOC-68650#test_anchor ). and when I am giving this url, the total url has to go to application B, but only http://google.com/DOC-68650 is going to application B. I want to include #test_anchor also while passing a url from A application to B appliaction.

Can anyone please tell me how to achieve this. Appreciate your help on this.

The fact that you're battling the Servlet API should be an indicator that you're going about whatever problem you're trying to solve the wrong way.

The proper approach is to take a step back and ask yourself *why* you want to do this. To me it sounds as if URL parameters might work as well, and would not make you jump through hoops to get it done.

Using Referer just like the Coderanch is done (they make it hidden in Login page). By using referer they pull back to same page after Login. For # included , you got to deal with javascript >> onsubmit then >>encodeURIComponent(). Is this correct ranchers ?

Gopi Gorantala wrote:How to check a url whether it is valid or not, Please include # symbol while validating the url using Java

Gopi, not sure if you are still searching for validating the url, however one of the existing Apache class: "UrlValidator" can be of some help for you to start validating the urls...check the below link: