Redirect request to another Tomcat server

View: New views
12 Messages — Rating Filter:   Alert me  

Redirect request to another Tomcat server

by Liang Xiao Zhu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everyone,

I am wondering, if there is some posibility to redirect the request from
one Tomcat Server to another one. I would like to know where is the
point to change that. Basically, in one Tomcat Server I recieve the
request I will check the headers and then depending of some parameters I
will redirect the same request to another Tomcat or not.

In fact, I have been looking at some files, such as,
Http11NioProtocol.java and Http11NioProcessor.java, because both files
are for managing the connector of Tomcat, in this case the connector
Coyote using NIO.

Thans in advance!!!

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Redirect request to another Tomcat server

by Hassan Schroeder-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, May 14, 2008 at 4:35 PM, ubekhet <ubekhet@...> wrote:

> I am wondering, if there is some posibility to redirect the request from one
> Tomcat Server to another one.

   <http://tuckey.org/urlrewrite/>  is probably the easiest  :-)

--
Hassan Schroeder ------------------------ hassan.schroeder@...

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Redirect request to another Tomcat server

by Johnny Kewl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


---------------------------------------------------------------------------
HARBOR: http://coolharbor.100free.com/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
---------------------------------------------------------------------------
----- Original Message -----
From: "ubekhet" <ubekhet@...>
To: <users@...>
Sent: Thursday, May 15, 2008 1:35 AM
Subject: Redirect request to another Tomcat server


> Hi everyone,
>
> I am wondering, if there is some posibility to redirect the request from
> one Tomcat Server to another one. I would like to know where is the
> point to change that. Basically, in one Tomcat Server I recieve the
> request I will check the headers and then depending of some parameters I
> will redirect the same request to another Tomcat or not.
>
> In fact, I have been looking at some files, such as,
> Http11NioProtocol.java and Http11NioProcessor.java, because both files
> are for managing the connector of Tomcat, in this case the connector
> Coyote using NIO.
>
> Thans in advance!!!

response.sendRedirect(newUrl);


> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@...
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Redirect request to another Tomcat server

by Liang Xiao Zhu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Johnny Kewl escribió:

>
> ---------------------------------------------------------------------------
>
> HARBOR: http://coolharbor.100free.com/index.htm
> The most powerful application server on earth.
> The only real POJO Application Server.
> ---------------------------------------------------------------------------
>
> ----- Original Message ----- From: "ubekhet" <ubekhet@...>
> To: <users@...>
> Sent: Thursday, May 15, 2008 1:35 AM
> Subject: Redirect request to another Tomcat server
>
>
>> Hi everyone,
>>
>> I am wondering, if there is some posibility to redirect the request
>> from one Tomcat Server to another one. I would like to know where is
>> the point to change that. Basically, in one Tomcat Server I recieve
>> the request I will check the headers and then depending of some
>> parameters I will redirect the same request to another Tomcat or not.
>>
>> In fact, I have been looking at some files, such as,
>> Http11NioProtocol.java and Http11NioProcessor.java, because both
>> files are for managing the connector of Tomcat, in this case the
>> connector Coyote using NIO.
>>
>> Thans in advance!!!
>
> response.sendRedirect(newUrl);
>
>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@...
>> To unsubscribe, e-mail: users-unsubscribe@...
>> For additional commands, e-mail: users-help@...
>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@...
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
Hi Johnny Kewl,

With response.sendRedirect(newUrl); I have to invoke this in some web
applications, but I want to modified Tomcat sources for to do that, and
the class Http11NioProtocol and Http11NioProcessor dont have
sendRedirect() methods!!!

Any idea for redirect the request from the connector NIO?

Thanks!!!!

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Parent Message unknown RE: Redirect request to another Tomcat server

by Propes, Barry L :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

you'd probably have to hard code an http path in there, but I don't think you could salvage a session could you? Maybe you could.

-----Original Message-----
From: ubekhet [mailto:ubekhet@...]
Sent: Wednesday, May 14, 2008 6:36 PM
To: users@...
Subject: Redirect request to another Tomcat server


Hi everyone,

I am wondering, if there is some posibility to redirect the request from
one Tomcat Server to another one. I would like to know where is the
point to change that. Basically, in one Tomcat Server I recieve the
request I will check the headers and then depending of some parameters I
will redirect the same request to another Tomcat or not.

In fact, I have been looking at some files, such as,
Http11NioProtocol.java and Http11NioProcessor.java, because both files
are for managing the connector of Tomcat, in this case the connector
Coyote using NIO.

Thans in advance!!!

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Redirect request to another Tomcat server

by Liang Xiao Zhu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, maybe you are right that I couldn't salvage a session. So, How can
manage that using as session, I mean can I redirect the Tomcat sessions?
For example, I detected a session that I dont want to response, and so I
want to redirect this session, How I have to do that?

Thanks in advance!!!

Propes, Barry L escribió:

> you'd probably have to hard code an http path in there, but I don't think you could salvage a session could you? Maybe you could.
>
> -----Original Message-----
> From: ubekhet [mailto:ubekhet@...]
> Sent: Wednesday, May 14, 2008 6:36 PM
> To: users@...
> Subject: Redirect request to another Tomcat server
>
>
> Hi everyone,
>
> I am wondering, if there is some posibility to redirect the request from
> one Tomcat Server to another one. I would like to know where is the
> point to change that. Basically, in one Tomcat Server I recieve the
> request I will check the headers and then depending of some parameters I
> will redirect the same request to another Tomcat or not.
>
> In fact, I have been looking at some files, such as,
> Http11NioProtocol.java and Http11NioProcessor.java, because both files
> are for managing the connector of Tomcat, in this case the connector
> Coyote using NIO.
>
> Thans in advance!!!
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@...
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@...
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>  


---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


RE: Redirect request to another Tomcat server

by Peter Crowther :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd write a Valve that pre-processes all of the incoming requests to the server.  It's capable of intercepting requests before the webapps see them, and it's capable of refusing to process.  I *think* you have, or can get, all the information you need at the point the valve runs.

                - Peter

> -----Original Message-----
> From: Liang Xiao Zhu [mailto:ubekhet@...]
> Sent: 15 May 2008 17:42
> To: Tomcat Users List
> Subject: Re: Redirect request to another Tomcat server
>
> Yes, maybe you are right that I couldn't salvage a session.
> So, How can
> manage that using as session, I mean can I redirect the
> Tomcat sessions?
> For example, I detected a session that I dont want to
> response, and so I
> want to redirect this session, How I have to do that?
>
> Thanks in advance!!!
>
> Propes, Barry L escribió:
> > you'd probably have to hard code an http path in there, but
> I don't think you could salvage a session could you? Maybe you could.
> >
> > -----Original Message-----
> > From: ubekhet [mailto:ubekhet@...]
> > Sent: Wednesday, May 14, 2008 6:36 PM
> > To: users@...
> > Subject: Redirect request to another Tomcat server
> >
> >
> > Hi everyone,
> >
> > I am wondering, if there is some posibility to redirect the
> request from
> > one Tomcat Server to another one. I would like to know where is the
> > point to change that. Basically, in one Tomcat Server I recieve the
> > request I will check the headers and then depending of some
> parameters I
> > will redirect the same request to another Tomcat or not.
> >
> > In fact, I have been looking at some files, such as,
> > Http11NioProtocol.java and Http11NioProcessor.java, because
> both files
> > are for managing the connector of Tomcat, in this case the connector
> > Coyote using NIO.
> >
> > Thans in advance!!!
> >
> >
> ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@...
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> >
> >
> ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@...
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@...
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Redirect request to another Tomcat server

by Liang Xiao Zhu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

But, what happen if I want using Session instead of Request? mean, I
want to refuse session according the number of session I have
currently!!! And them redirect the refused session to other tomcat
server!!!!

Thanks


Peter Crowther escribió:

> I'd write a Valve that pre-processes all of the incoming requests to the server.  It's capable of intercepting requests before the webapps see them, and it's capable of refusing to process.  I *think* you have, or can get, all the information you need at the point the valve runs.
>
>                 - Peter
>
>  
>> -----Original Message-----
>> From: Liang Xiao Zhu [mailto:ubekhet@...]
>> Sent: 15 May 2008 17:42
>> To: Tomcat Users List
>> Subject: Re: Redirect request to another Tomcat server
>>
>> Yes, maybe you are right that I couldn't salvage a session.
>> So, How can
>> manage that using as session, I mean can I redirect the
>> Tomcat sessions?
>> For example, I detected a session that I dont want to
>> response, and so I
>> want to redirect this session, How I have to do that?
>>
>> Thanks in advance!!!
>>
>> Propes, Barry L escribió:
>>    
>>> you'd probably have to hard code an http path in there, but
>>>      
>> I don't think you could salvage a session could you? Maybe you could.
>>    
>>> -----Original Message-----
>>> From: ubekhet [mailto:ubekhet@...]
>>> Sent: Wednesday, May 14, 2008 6:36 PM
>>> To: users@...
>>> Subject: Redirect request to another Tomcat server
>>>
>>>
>>> Hi everyone,
>>>
>>> I am wondering, if there is some posibility to redirect the
>>>      
>> request from
>>    
>>> one Tomcat Server to another one. I would like to know where is the
>>> point to change that. Basically, in one Tomcat Server I recieve the
>>> request I will check the headers and then depending of some
>>>      
>> parameters I
>>    
>>> will redirect the same request to another Tomcat or not.
>>>
>>> In fact, I have been looking at some files, such as,
>>> Http11NioProtocol.java and Http11NioProcessor.java, because
>>>      
>> both files
>>    
>>> are for managing the connector of Tomcat, in this case the connector
>>> Coyote using NIO.
>>>
>>> Thans in advance!!!
>>>
>>>
>>>      
>> ---------------------------------------------------------------------
>>    
>>> To start a new topic, e-mail: users@...
>>> To unsubscribe, e-mail: users-unsubscribe@...
>>> For additional commands, e-mail: users-help@...
>>>
>>>
>>>
>>>      
>> ---------------------------------------------------------------------
>>    
>>> To start a new topic, e-mail: users@...
>>> To unsubscribe, e-mail: users-unsubscribe@...
>>> For additional commands, e-mail: users-help@...
>>>
>>>
>>>      
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@...
>> To unsubscribe, e-mail: users-unsubscribe@...
>> For additional commands, e-mail: users-help@...
>>
>>
>>    
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@...
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>  


---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


RE: Redirect request to another Tomcat server

by Peter Crowther :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> From: Liang Xiao Zhu [mailto:ubekhet@...]
> But, what happen if I want using Session instead of Request? mean, I
> want to refuse session according the number of session I have
> currently!!! And them redirect the refused session to other tomcat
> server!!!!

You are taking an action when a request comes in.  There is no other time at which you can take an action to redirect a request.

The action you are taking is to choose whether to redirect the request based on a) whether it already has a session on this server, b) how many sessions this server has.  You can detect both of these in the valve, and make a decision.

By the way, it sounds like you are writing a load-balancing framework.  You are aware that Tomcat already has one?

                - Peter

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Redirect request to another Tomcat server

by Johnny Kewl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Hi Johnny Kewl,
>
> With response.sendRedirect(newUrl); I have to invoke this in some web
> applications, but I want to modified Tomcat sources for to do that, and
> the class Http11NioProtocol and Http11NioProcessor dont have
> sendRedirect() methods!!!
>
> Any idea for redirect the request from the connector NIO?
>
> Thanks!!!!

Honestly, never used NIO, didnt know it had no redirect, sorry I answered
too quick.

But heres a guess, its where I would start looking...

First remember that you dont have any session control now.
You working between machines... so it cant be thought of like a forward...

A forward... gets a request and then passes it on to another servlet and
only works within the webapp.
But a redirect... effectively says to the browser... "wrong place, I cant
help you, talk to the other dude"... and the browser forgets about you and
"starts again".
So shared sessions, if you need that are going to be hidden form fields or
encoded urls... but not normal cookie stuff.

If that is still OK, then remember that all a redirect actually is... is a
HTTP header... I think its status 302 or something... and I imagine that in
NIO, one must be able to set the headers somehow... so event fires... you
read some headers... you make your own response 302 headers which will have
the new url... and just return them... browser will go, "oops I gotta talk
to someone else". I cant remember the details but there are even status
codes in HTTP, the will make the browser never talk to you again... make
sure you get the right ones ;)  I tried it on the ex wife... didnt work...
not http compliant ;)

The reason redirects are avoided normally is because its a round trip to the
browser...

I think thats the story... more or less,  havnt build up the courage to
tackle the comet stuff yet ;)

---------------------------------------------------------------------------
HARBOR: http://coolharbor.100free.com/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
---------------------------------------------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Redirect request to another Tomcat server

by Johnny Kewl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Liang,

I think whats bothering all of us, is that sometimes the concept itself is
going wrong, and that what I think the other guys are asking.
As you can see, you now getting into cookie management and all that heavy
stuff, and eventually maybe suicide ;)

If its load sharing, maybe think about putting it behind Apache and using a
JK connector. I'm not sure if there or NIO issues there, maybe the other
guys can comment... but if something like that is possible, then your
servlets are standard and JK is watching sessions and doing all that for
you.
Just a thought..

> ---------------------------------------------------------------------------
> HARBOR: http://coolharbor.100free.com/index.htm
> The most powerful application server on earth.
> The only real POJO Application Server.
Only appearing once now in emails ;)
> ---------------------------------------------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Redirect request to another Tomcat server

by Alan Chaney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Liang

I don't understand what NIO has to do with it. The
response.sendRedirect() is part of the servlet spec and what type
connector you are using in Tomcat should have no effect on this. I'd
appreciate it if someone would correct me here if I am wrong. As a
matter of interest I use redirects extensively on tomcats with NIO, APR
and the standard  connector and they all work ok.


As Johnny K correctly observed and as its name implies it sends a
'redirect' 302 response to the browser. As also observed the 'session'
is a UNIQUE relationship between the server and the browser. I think it
would be helpful if the you actually clarified exactly the purpose of
redirecting from one tomcat instance to another.

On another point from the your earlier message you talk of a 'refused
session' being the reason for a redirect. AFAIKS a 'refused session' is
no session at all. Maybe a better way of putting it is refusing to start
a new session? Sending a redirect would allow a session to be created
between the browser and the 2nd server. But it does sound suspiciously
like load balancing to me... and of course there is the issue of making
sessions sticky. So I would agree with Johnny and others as below, use
something like mod_jk and a cluster.



Regards

Alan Chaney



Johnny Kewl wrote:

> Liang,
>
> I think whats bothering all of us, is that sometimes the concept itself
> is going wrong, and that what I think the other guys are asking.
> As you can see, you now getting into cookie management and all that
> heavy stuff, and eventually maybe suicide ;)
>
> If its load sharing, maybe think about putting it behind Apache and
> using a JK connector. I'm not sure if there or NIO issues there, maybe
> the other guys can comment... but if something like that is possible,
> then your servlets are standard and JK is watching sessions and doing
> all that for you.
> Just a thought..
>
>> ---------------------------------------------------------------------------
>>
>> HARBOR: http://coolharbor.100free.com/index.htm
>> The most powerful application server on earth.
>> The only real POJO Application Server.
> Only appearing once now in emails ;)
>> ---------------------------------------------------------------------------
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@...
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>
> !DSPAM:482c8ec0298441572928584!
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...