Re: How to get port of a running Tomcat instance

2007-08-23 Thread Vamsavardhana Reddy
I do not know if this info is helpful...  ServletRequest has getServerPort()
and getServerName() methods that should give the port and server through
which the request came.

Vamsi

On 8/24/07, Brian Barnett [EMAIL PROTECTED] wrote:

 Can someone provide a java code snippet showing how to get the port that
 Tomcat is listening on? Is there a way to access the settings in the
 server.xml file from within a running instance of Tomcat?

 I'm running a Struts-based app on Tomcat 5.5 (multiple Tomcat instances
 actually) and need to know which port a request just came in on. Ideally,
 I
 would like to set an application scope variable at startup, in a plugin
 class. The plugin class has access to ServletContext and a ModuleConfig
 object, but I was not able to find a way to get the port through those
 objects. Maybe I'm missing it. I looked through ServletContext object and
 could not find it. Could not find access to Catalina's HttpConnector class
 anywhere.

 Thanks,
 Brian Barnett


 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to get port of a running Tomcat instance

2007-08-23 Thread David Delbecq

http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getLocalPort()

You can only get the port from a request. This is because a sepecific 
webapp can be served from serveral hostname and from several port, all 
sharing same instance of servlet.


(basic example is tomcat with virtual hosting activated and listening on 
both plain 8080 port and SSL port)


Brian Barnett a écrit :

Can someone provide a java code snippet showing how to get the port that
Tomcat is listening on? Is there a way to access the settings in the
server.xml file from within a running instance of Tomcat?

I'm running a Struts-based app on Tomcat 5.5 (multiple Tomcat instances
actually) and need to know which port a request just came in on. Ideally, I
would like to set an application scope variable at startup, in a plugin
class. The plugin class has access to ServletContext and a ModuleConfig
object, but I was not able to find a way to get the port through those
objects. Maybe I'm missing it. I looked through ServletContext object and
could not find it. Could not find access to Catalina's HttpConnector class
anywhere.

Thanks,
Brian Barnett


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
  


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: How to get port of a running Tomcat instance

2007-08-23 Thread Brian Barnett
Yes of course, that makes sense. I will use Vamsi's suggestion with
ServletRequest.getServerPort(). Thank you.

-Original Message-
From: David Delbecq [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 23, 2007 2:03 PM
To: Tomcat Users List
Subject: Re: How to get port of a running Tomcat instance


http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getL
ocalPort()

You can only get the port from a request. This is because a sepecific
webapp can be served from serveral hostname and from several port, all
sharing same instance of servlet.

(basic example is tomcat with virtual hosting activated and listening on
both plain 8080 port and SSL port)

Brian Barnett a écrit :
 Can someone provide a java code snippet showing how to get the port that
 Tomcat is listening on? Is there a way to access the settings in the
 server.xml file from within a running instance of Tomcat?

 I'm running a Struts-based app on Tomcat 5.5 (multiple Tomcat instances
 actually) and need to know which port a request just came in on. Ideally,
I
 would like to set an application scope variable at startup, in a plugin
 class. The plugin class has access to ServletContext and a ModuleConfig
 object, but I was not able to find a way to get the port through those
 objects. Maybe I'm missing it. I looked through ServletContext object and
 could not find it. Could not find access to Catalina's HttpConnector class
 anywhere.

 Thanks,
 Brian Barnett


 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]