tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <>
Subject RE: Role of HttpServer
Date Thu, 20 Jan 2000 14:51:20 GMT

> > Is there something special about that port compared to all the
> other ports
> > on which the ContextManager's connectors may be listing. As far as I can
> > tell the ContextManager's port and hostname values are only used for the
> > naming of entries in the workdir. Perhaps giving ContextManager a name
> > attribute and using it to name the workdir would be as good.
> :-)
> It's the "real" hostname and port.
> You may have tomcat on a different computer with Apache on the main
> web server. Servlet.getPort(), getHostname() need to respond with
>  the name and port of the real web server ( != adapter port and local
> hostname).

OK I understand the motivation. Unfortunately it isn't actually used like
that currently as far as I can tell. The only calls to getHostname and
getPort on the ContextManager are by the workdir code.

By Servlet.getPort and getHostname() I am presuming you actually mean
ServletRequest.getServerPort() and ServletRequest.getServerName()? Looking
at the Tomcat code, these methods are actually implemented in RequestImpl
and HttpRequestAdapter. For both of these classes the serverName can be set
explicitly otherwise it defaults to the value of the host header or the
value "localhost". The port value in RequestImpl can be set explicitly or
defaults to 8080. For the HttpRequestAdapter the port Value comes from the
local port of the socket used to receive the request.

The serverPort is set explicitly by AJPRequestAdapter in
by AJP12RequestAdapter in AJP12ConnectionHandler, and in ConnectorRequest
invoked by AJP23ConnectionHandler

The serverName is set explicitly by Ajp12ConnectionHandler and in the
HttpConnectionHandler it is set from the host header or from the local
address of the receiving socket.

The result of all that is that it seems to me to be possible for the
connectors to set the server name and server port to appropriate values
without needing those values to be held by the ContextManager. Where the
server is remote, the protocol supplies the info, where tomcat is providing
the HTTP connection, the info comes from the local side of the socket.

What happens if the ContextManager has the wrong values (ie the server which
sends the request is not the one which is identified in the ContextManager)?
Should I need to change the tomcat config to move my Apache server to a
different port?

I don't know why all the connectors don't set the serverName. I don't have a
detailed understanding of the AJP protocols.

> Tomcat still have "legacy" code from the "standalone" case, HttpServer
> used to implement the http server,

I started this thread wondering if we can remove that legacy code.

> we added ContextManager because
> in a "multi-adapter" server you can have more complex models.
> ( ContextManager is not a singleton - you can have multiple
> instances, each handling a different web server )


> > A model whereby a contextManager contains a set of connectors
> (and contexts,
> > interceptors, etc) and all port information is managed by those
> connectors
> > seems more regular to me. This seems to correspond to the model in
> > tomcat.xml but not yet in the code.
> Except the "default" port a hostname, which is different from what
> adapters have.

Sure, but the connectors can set the values appropriately without referring
to the ContextManager. So I still think the port information can be defined
solely in the connectors.

I am wondering whether a single ContextManager can talk to more than one
Apache server. I haven't thought whether that would be useful but it would
mean that the ContextManager can't know about a single "real" hostname and
port. The real host info would need to come from the connectors.


View raw message