You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by William Wishon <bi...@pictureiq.com> on 2001/03/01 22:50:41 UTC
Assigning Servlets to different ports.
Hi,
I am trying to assign one of my servlets (say servlet1) to port 8080 and
another one (say servlet2) to port 8081. I want them totally separate so
that I can't access servlet2 on port 8080 nor servlet1 on 8081. Can anyone
help me figure out how to do this?
-Bill
Re: Assigning Servlets to different ports.
Posted by Alex Fernández <af...@tid.es>.
Hi William!
Configure two contexts, and load each servlet in one context.
Un saludo,
Alex.
William Wishon wrote:
> Hi,
>
> I am trying to assign one of my servlets (say servlet1) to port 8080 and
> another one (say servlet2) to port 8081. I want them totally separate so
> that I can't access servlet2 on port 8080 nor servlet1 on 8081. Can anyone
> help me figure out how to do this?
>
> -Bill
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org
Re: Assigning Servlets to different ports.
Posted by Alex Fernández <af...@tid.es>.
Hi William!
Sorry, I'm out of my depth here. I had the impression that two ContextManager's
would work, but I had not tested it.
Perhaps someone more knowledgeable will care to answer your questions.
Un saludo,
Alex.
William Wishon wrote:
> > In Tomcat 3.3, you can setup two different ContextManager's, so
> > each will listen to a
> > different port. I believe it should be the same in 3.2.1?
>
> In the configuration I am looking at (for Tomcat 3.2.1) it looks like the
> connectors are where the port numbers get assigned. Is there a port
> property that can be set on the ContextManager? If so do you know how it
> interacts with the port settings on the Connectors? I have been playing
> around with multiple ContextManagers each with a TcpPoolConnector with
> different port settings and different Hosts with Contexts mapping different
> servlets to "/", but I haven't yet found a combination that works for me.
> I've even tried giving each ContextManager its own home directory, work dir,
> webapps dir, etc.
>
> I'm going to keep fiddling around and looking through the code to see what I
> can find, but it you have any more suggestions please post them.
>
> The thing I am looking into now are a few properties of the TcpPoolConnector
> that look promising, they are 'vhost_port', 'vhost_name', and
> 'vhost_address'. I tried what seemed obvious to me, with no luck. I have
> yet to discover how these settings on the Connector interact with the
> Contexts that are part of the Hosts. In my grep'ing through the source the
> only place I've found that looks at these values is
> org/apache/tomcat/startup/EmbededTomcat.java, which didn't look promising,
> so maybe they are for a feature not yet implemented.
>
> > > I also want the default servlet mappings turned off so
> > that I am no longer
> > > able to access the servlets as "/webapp_name/" when tomcat
> > starts and finds
> > > a war file named "webapp_name". I only want Tomcat to serve
> > the servlets
> > > that I setup explicitly in server.xml.
> >
> > I'm at a loss here. Isn't web.xml the file that sets servlets up?
>
> I figured out how to do that, by removing the AutoSetup ContextInterceptor I
> was able to get stop tomcat from installing the webapps it finds
> webapps/foo.war into http://host/foo/
> This has the other side effect of not automatically exploding war files that
> it finds in the webapps directory, but that's fine by me.
>
> > > That gives me a different document root for each port. What I want from
> > > Tomcat is a different servlet to handle requests on each port.
> >
> > With two ContextManager's you should be able to do what you want;
> > I haven't tried it,
> > though.
>
> One kind message I get when using two ContextManagers are messages about the
> removing of duplicate servlets. Now I have all sorts of debug flags turned
> on so they might be harmless, but I don't get the messages with only one
> ContextManager.
>
> Thanks,
> Bill
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org
RE: Assigning Servlets to different ports.
Posted by William Wishon <bi...@pictureiq.com>.
> In Tomcat 3.3, you can setup two different ContextManager's, so
> each will listen to a
> different port. I believe it should be the same in 3.2.1?
In the configuration I am looking at (for Tomcat 3.2.1) it looks like the
connectors are where the port numbers get assigned. Is there a port
property that can be set on the ContextManager? If so do you know how it
interacts with the port settings on the Connectors? I have been playing
around with multiple ContextManagers each with a TcpPoolConnector with
different port settings and different Hosts with Contexts mapping different
servlets to "/", but I haven't yet found a combination that works for me.
I've even tried giving each ContextManager its own home directory, work dir,
webapps dir, etc.
I'm going to keep fiddling around and looking through the code to see what I
can find, but it you have any more suggestions please post them.
The thing I am looking into now are a few properties of the TcpPoolConnector
that look promising, they are 'vhost_port', 'vhost_name', and
'vhost_address'. I tried what seemed obvious to me, with no luck. I have
yet to discover how these settings on the Connector interact with the
Contexts that are part of the Hosts. In my grep'ing through the source the
only place I've found that looks at these values is
org/apache/tomcat/startup/EmbededTomcat.java, which didn't look promising,
so maybe they are for a feature not yet implemented.
> > I also want the default servlet mappings turned off so
> that I am no longer
> > able to access the servlets as "/webapp_name/" when tomcat
> starts and finds
> > a war file named "webapp_name". I only want Tomcat to serve
> the servlets
> > that I setup explicitly in server.xml.
>
> I'm at a loss here. Isn't web.xml the file that sets servlets up?
I figured out how to do that, by removing the AutoSetup ContextInterceptor I
was able to get stop tomcat from installing the webapps it finds
webapps/foo.war into http://host/foo/
This has the other side effect of not automatically exploding war files that
it finds in the webapps directory, but that's fine by me.
> > That gives me a different document root for each port. What I want from
> > Tomcat is a different servlet to handle requests on each port.
>
> With two ContextManager's you should be able to do what you want;
> I haven't tried it,
> though.
One kind message I get when using two ContextManagers are messages about the
removing of duplicate servlets. Now I have all sorts of debug flags turned
on so they might be harmless, but I don't get the messages with only one
ContextManager.
Thanks,
Bill
Re: Assigning Servlets to different ports.
Posted by Alex Fernández <af...@tid.es>.
Someone please correct me if I'm wrong here, since it seems important for William --
and eventually it's an important capability, I don't want to mislead anyone.
William Wishon wrote:
> Here's the problem I keep running up against.
>
> The top level XML element is a Server, it contains a ContextManager. The
> ContextManager contains both the Connector, which defines the port to listen
> on, and the Context entries at the same level. How do I associate
> particular contexts with particular Connectors? Right now I seem only able
> to have one servlet context that maps to "/". I really should be able to
> have two servlets that map to "/", one "/" for port 8080 and one "/" for
> port 8081.
In Tomcat 3.3, you can setup two different ContextManager's, so each will listen to a
different port. I believe it should be the same in 3.2.1?
> I also want the default servlet mappings turned off so that I am no longer
> able to access the servlets as "/webapp_name/" when tomcat starts and finds
> a war file named "webapp_name". I only want Tomcat to serve the servlets
> that I setup explicitly in server.xml.
I'm at a loss here. Isn't web.xml the file that sets servlets up?
[snip -- apache configuration here]
> That gives me a different document root for each port. What I want from
> Tomcat is a different servlet to handle requests on each port.
With two ContextManager's you should be able to do what you want; I haven't tried it,
though.
Un saludo,
Alex.
RE: Assigning Servlets to different ports.
Posted by William Wishon <bi...@pictureiq.com>.
Here's the problem I keep running up against.
The top level XML element is a Server, it contains a ContextManager. The
ContextManager contains both the Connector, which defines the port to listen
on, and the Context entries at the same level. How do I associate
particular contexts with particular Connectors? Right now I seem only able
to have one servlet context that maps to "/". I really should be able to
have two servlets that map to "/", one "/" for port 8080 and one "/" for
port 8081.
I also want the default servlet mappings turned off so that I am no longer
able to access the servlets as "/webapp_name/" when tomcat starts and finds
a war file named "webapp_name". I only want Tomcat to serve the servlets
that I setup explicitly in server.xml.
One way of achieving this in an apache world would be:
NameVirtualHost 10.0.0.1:8080
NameVirtualHost 10.0.0.1:8081
<VirtualHost 10.0.0.1:8080>
ServerName port8080.domain.com
DocumentRoot /home/httpd/port8080
....
</VirtualHost>
<VirtualHost 10.0.0.1:8081>
ServerName port8081.domain.com
DocumentRoot /home/httpd/port8081
....
</VirtualHost>
That gives me a different document root for each port. What I want from
Tomcat is a different servlet to handle requests on each port.
-Bill
> -----Original Message-----
> From: Alex Fernández [mailto:afm229@tid.es]
> Sent: Friday, March 02, 2001 4:07 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Assigning Servlets to different ports.
>
>
> Hi William!
>
> Configure two contexts, and load each servlet in one context.
>
> Un saludo,
>
> Alex.
>
> William Wishon wrote:
>
> > Hi,
> >
> > I am trying to assign one of my servlets (say servlet1)
> to port 8080 and
> > another one (say servlet2) to port 8081. I want them totally
> separate so
> > that I can't access servlet2 on port 8080 nor servlet1 on 8081.
> Can anyone
> > help me figure out how to do this?
> >
> > -Bill
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, email: tomcat-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org
Re: Assigning Servlets to different ports.
Posted by Alex Fernández <af...@tid.es>.
Hi William!
Configure two contexts, and load each servlet in one context.
Un saludo,
Alex.
William Wishon wrote:
> Hi,
>
> I am trying to assign one of my servlets (say servlet1) to port 8080 and
> another one (say servlet2) to port 8081. I want them totally separate so
> that I can't access servlet2 on port 8080 nor servlet1 on 8081. Can anyone
> help me figure out how to do this?
>
> -Bill
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org