In Java EE, how can I dynamically retrieve the full URL for my application?
For example, if the URL is "localhost:8080/myapplication/", I would like a method that can simply return this to me, either as a String or something else.
I am running GlassFish as application server.
Inside any servlet or filter you have access to
HttpServletRequestwhich allows you to see what URL was used by the client to access your application, e.g. tryHttpServletRequest.getRequestURL().