java - Get domain name in url with JSTL? -


I am trying to get the domain name from URL with JSTL. 2 ways I know that the wrong information comes back. What exactly do I need in url

When I do:

  $ {pageContext.request.remoteHost}  

I get my server IP.

When I do:

  $ {pageContext.request.serverName}  

I usually get the right domain name , But we have on the server

Anyone know how I can get the current domain name in the URL

P > I may have to meet the URL and then parse it. How can I go about doing this?

You can use it:

to request Uses the URL used to reconstruct. Returned URL contains a protocol, server name, port number and server path, but does not include query string parameters.

This will return as a string

After that the string comes after (http, https, etc.) and to parse it to find first Should be trivial


Comments