On 17/09/2010 15:15, Paritosh Patel wrote: > My web application needs to know the server IP/Port address during > its initialization. How can I determine that? (I was trying to stay > server agnostic as much as possible... if that is not possible, then I > will write specific code for Tomcat. > > I have searched everywhere for this answer on the web and in this forum.
Everywhere on the web? Even Google can't manage that. > I understand it can be found from the HttpServletRequest class, but that is > too late. > > I have a servlet context listener, but I cannot get the IP address from > there either. > > I would appreciate any help or ideas on this. Thanks. Tomcat listens on whichever IP address is configured in your connector. If you don't specify an IP address, then it listens on 0.0.0.0. HttpServletRequest will only tell you what the client requested, which may or may not be the correct answer, depending on whether your app is behind a proxy or not. The point I'm making is that Tomcat might not know the address you want/need. java.net.InetAddress may help, depending on what it is you're actually trying to achieve. There was a discussion about this last year, if I remember correctly, you may wish to search the archives again. p
0x62590808.asc
Description: application/pgp-keys
signature.asc
Description: OpenPGP digital signature