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]

Reply via email to