You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nikita Tovstoles <ni...@eviltwinstudios.net> on 2006/05/03 19:50:41 UTC

how to configure servlets within same webapp to listen to different local ports?

Hi,

I have a webapp with two servlets: LoginServlet and AdminServlet. I 
would like LoginServlet to only respond to requests coming to port 8080, 
and AdminServlet to respond to requests coming only to 8081. The only 
(rather non-portable way of doing this) of which I can think so far is:

-in server.xml define two Connectors: for port 8080, and port 8081
-in LoginServlet's processRequest() do:

if (request.getLocalPort() != 8080)
{
    //abort
}
-Implement similar 'if' statement in AdminServlet but using '8081'.

-I can move actual port numbers into web.xml as properties, but that is 
still not very portable.

This is OK, but is there any way to do this without specifying port 
numbers in the webapp itself?

thanks

-nikita


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: how to configure servlets within same webapp to listen to different local ports?

Posted by Chris Berthold <cb...@styleline.com>.
Multiple connectors is designed for allowing different protocols to access
tomcat, for instance AJP 1.2, AJP1.3, HTTP, HTTPS, etc.

Having multiple services is designed so that you can create multiple
separate instances of tomcat within itself without the overhead of having to
reload the extra core parts of Tomcat before the service starts.  

What you were asking for was a separation of LoginServlet and AdminServlet
to two different ports.  You are asking for a separation in the context the
servlets run in and so creating multiple services would do it.  No need to
code in which port they should need to be in.  Everything would also react
as if the other servlet does not exist, because it doesn't.


Chris Berthold
IT Systems Analyst
Commercial Refrigerator Door Company
941 . 371 . 8110 x 205

-----Original Message-----
From: Nikita Tovstoles [mailto:nikita@eviltwinstudios.net] 
Sent: Wednesday, May 03, 2006 4:00 PM
To: Tomcat Users List
Subject: Re: how to configure servlets within same webapp to listen to
different local ports?

Thanks for your take. Could you please explain why setting up multiple 
services is better than multiple connectors?

thanks
-nikita

Chris Berthold wrote:
> Your on the right path.  Instead of multiple connectors though, you need
to
> setup multiple services with a single connector on a different port.  You
> will end up with essentially two web roots and applications under each.
>
>
> Chris Berthold
> IT Systems Analyst
> Commercial Refrigerator Door Company
> 941 . 371 . 8110 x 205
>
> -----Original Message-----
> From: Nikita Tovstoles [mailto:nikita@eviltwinstudios.net] 
> Sent: Wednesday, May 03, 2006 1:51 PM
> To: Tomcat Users List
> Subject: how to configure servlets within same webapp to listen to
different
> local ports?
>
> Hi,
>
> I have a webapp with two servlets: LoginServlet and AdminServlet. I 
> would like LoginServlet to only respond to requests coming to port 8080, 
> and AdminServlet to respond to requests coming only to 8081. The only 
> (rather non-portable way of doing this) of which I can think so far is:
>
> -in server.xml define two Connectors: for port 8080, and port 8081
> -in LoginServlet's processRequest() do:
>
> if (request.getLocalPort() != 8080)
> {
>     //abort
> }
> -Implement similar 'if' statement in AdminServlet but using '8081'.
>
> -I can move actual port numbers into web.xml as properties, but that is 
> still not very portable.
>
> This is OK, but is there any way to do this without specifying port 
> numbers in the webapp itself?
>
> thanks
>
> -nikita
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: how to configure servlets within same webapp to listen to different local ports?

Posted by Nikita Tovstoles <ni...@eviltwinstudios.net>.
Thanks for your take. Could you please explain why setting up multiple 
services is better than multiple connectors?

thanks
-nikita

Chris Berthold wrote:
> Your on the right path.  Instead of multiple connectors though, you need to
> setup multiple services with a single connector on a different port.  You
> will end up with essentially two web roots and applications under each.
>
>
> Chris Berthold
> IT Systems Analyst
> Commercial Refrigerator Door Company
> 941 . 371 . 8110 x 205
>
> -----Original Message-----
> From: Nikita Tovstoles [mailto:nikita@eviltwinstudios.net] 
> Sent: Wednesday, May 03, 2006 1:51 PM
> To: Tomcat Users List
> Subject: how to configure servlets within same webapp to listen to different
> local ports?
>
> Hi,
>
> I have a webapp with two servlets: LoginServlet and AdminServlet. I 
> would like LoginServlet to only respond to requests coming to port 8080, 
> and AdminServlet to respond to requests coming only to 8081. The only 
> (rather non-portable way of doing this) of which I can think so far is:
>
> -in server.xml define two Connectors: for port 8080, and port 8081
> -in LoginServlet's processRequest() do:
>
> if (request.getLocalPort() != 8080)
> {
>     //abort
> }
> -Implement similar 'if' statement in AdminServlet but using '8081'.
>
> -I can move actual port numbers into web.xml as properties, but that is 
> still not very portable.
>
> This is OK, but is there any way to do this without specifying port 
> numbers in the webapp itself?
>
> thanks
>
> -nikita
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: how to configure servlets within same webapp to listen to different local ports?

Posted by Chris Berthold <cb...@styleline.com>.
Your on the right path.  Instead of multiple connectors though, you need to
setup multiple services with a single connector on a different port.  You
will end up with essentially two web roots and applications under each.


Chris Berthold
IT Systems Analyst
Commercial Refrigerator Door Company
941 . 371 . 8110 x 205

-----Original Message-----
From: Nikita Tovstoles [mailto:nikita@eviltwinstudios.net] 
Sent: Wednesday, May 03, 2006 1:51 PM
To: Tomcat Users List
Subject: how to configure servlets within same webapp to listen to different
local ports?

Hi,

I have a webapp with two servlets: LoginServlet and AdminServlet. I 
would like LoginServlet to only respond to requests coming to port 8080, 
and AdminServlet to respond to requests coming only to 8081. The only 
(rather non-portable way of doing this) of which I can think so far is:

-in server.xml define two Connectors: for port 8080, and port 8081
-in LoginServlet's processRequest() do:

if (request.getLocalPort() != 8080)
{
    //abort
}
-Implement similar 'if' statement in AdminServlet but using '8081'.

-I can move actual port numbers into web.xml as properties, but that is 
still not very portable.

This is OK, but is there any way to do this without specifying port 
numbers in the webapp itself?

thanks

-nikita


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org