>From what I know, you cannot, but you can put the ports in the
context parameters in web.xml and get these parameters from within servlets
and JSP.
  <context-param>
    <param-name>connectorPort</param-name>
    <param-value>8007</param-value>
  </context-param>

which you can retrieve from a servlet by calling:

  getServletContext().getInitParameter("connectorPort");
or
  Connector port is <%= application.getInitParameter("connectorPort") %>
in JSP

The connectors are not part of the spec, and you can only get this
information by modifying the Tomcat itself and adding methods which could
retrieve this information. Of course it would be totally unstandard and
unportable (but in a sense, connectors are not standard anyhow), and
I am not even sure how you could get to this information easily, since the
your classloader does not know about Tomcat classes in the
org.apache.tomcat.service.whatever... You could probably make them write
something to some static bean where you can get it, but again... This is
for gurus to tell us, since I would be rediscovering the wheel going through
the Tomcat source...

Jan

On Thu, 13 Sep 2001, Tony Vinayak wrote:

> Greetings,
> 
> Am using Tomcat 3.2 with mod_jk and Apache 1.3.20
> 
> In my servlet, doing request.getServerPort() tells me the port on which
> Apache is listening (e.g. 80). How can I get to the Port on which Tomcat
> connector (ajp13) is listening (e.g. 8007) ??
> 
> regards,
> Tony
> 

Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
Ohio Supercomputer Center    |    Internet: [EMAIL PROTECTED] 
1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
Columbus, OH 43212-1163      |    http://www.osc.edu/

Reply via email to