tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <>
Subject Re: Getting Host information from within webapp
Date Thu, 10 Jun 2004 16:32:38 GMT
Would request.getServerName() work?


Kevin McAllister wrote:

> Kevin McAllister wrote:
>> I am using tomcat 4.1.29, and would like to obtain the host name 
>> attribute from within my servlet code for the associated context in 
>> which I am running.  I think I would be able to retrieve this 
>> information utilizing the JMX stuff
> Upon doing some further research I found I would be able to get a host 
> name given a context as long as my webapp was privileged (so the 
> org.apache.catalina.mbean.ServerLifecycleListener would place a 
> reference to the MBeanServer in the ServletContext attributes) However, 
> it seems the only information I would have to Query the MBeanServer is 
> the context path, And if I have more than one context path which is the 
> same (on different Hosts obviously) then I would not be able to uniquely 
> Identify the Host to which I am bound.  And since I will most certainly 
> have many Hosts each with the same context path for my webapp, this 
> method will not work for my purposes.
> Hopefully the information is available somewhere else, or otherwise I 
> may be able to obtain it by inserting another ServerLifeCycleListener 
> that can gather the information from the context adding event and put it 
> on the ServletContext attributes.
> - Kevin
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message