I think I miss read your question.
You wanted to know how to access the URL from a button click?
What URL?
As you know, your button will submit the page to the server for processing. Are you trying to store the URL of the page that the button submitted to? I'm really not sure why you would want to do this but this is possible.
First we need to cover a few things...
JSP pages and other Java hosted web applications require a web server component to handle page requests from browsers. The web server I used to use many years ago was
Tomcat Apache. I'm pretty sure it is the server you are using now.
When Apache receives a request it determines what code should be executed to handle the request and then creates a
context for the Java code to run under. In your Java code, you can use the PageContext you can access the requested URL through PageContext.request.contextPath property.
If you are trying to store some other URL that is somehow submitted to your jsp code, then you need to explain where you are getting that URL from.
It has been a very very long time since I've developed Java applications and I don't know how much further I can help you.
I moved your question to the Java forum since your question has nothing to do with JavaScript.
-Frinny