You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Zohar <da...@hotmail.com> on 2006/07/11 13:12:24 UTC

forwarding to a remote host

Hello list,
I have a servlet that handles POST requests. Sometimes the request needs to be forwarded to a different servlet, which may be running on a different server. What is the best way to do that?
Thanks,
Zohar.

Re: forwarding to a remote host

Posted by Vinu Varghese <vi...@x-minds.org>.
Hi Zohar
Check this 
http://marc.theaimsgroup.com/?l=tomcat-user&m=108568149602563&w=2 
<http://marc.theaimsgroup.com/?l=tomcat-user&m=108568149602563&w=2>

Hope this helps

- Regards
Vinu

Zohar wrote:
> Hello list,
> I have a servlet that handles POST requests. Sometimes the request needs to be forwarded to a different servlet, which may be running on a different server. What is the best way to do that?
> Thanks,
> Zohar.
>   

-- 
........................................

Vinu Varghese
vinu@x-minds.org
www.x-minds.org


Re: forwarding to a remote host

Posted by Avi Deitcher <av...@deitcher.net>.
Get the params from the request and then populate them in the Post. I
don't know of any automatic method.

Zohar wrote:

> What's the easiest way to transfer all the data from the Request to
> the PostMethod?
>
> ----- Original Message ----- From: "Avi Deitcher" <av...@deitcher.net>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Tuesday, July 11, 2006 14:38
> Subject: Re: forwarding to a remote host
>
>
>> Zohar,
>> - In the same host & context, use RequestDispatcher.forward()
>> - In the same host but different context, if cross-context enabled, get
>> the RequestDispatcher for that context then use forward()
>> - Different host entirely, or cross-context not enabled, you will
>> probably need to rebuild the request. I usually use the Jakarta Commons
>> HTTPClient for this. Check out
>> http://jakarta.apache.org/commons/httpclient/
>>
>> Anyone have a better suggestion?
>>
>> Avi
>>
>> Zohar wrote:
>>
>>> Hello list,
>>> I have a servlet that handles POST requests. Sometimes the request
>>> needs to be forwarded to a different servlet, which may be running
>>> on a different server. What is the best way to do that?
>>> Thanks,
>>> Zohar.
>>>
>>>
>>
>> -- 
>> ______________________________
>> Avi Deitcher
>> avi@deitcher.net
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

-- 
______________________________
Avi Deitcher
avi@deitcher.net



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


Re: forwarding to a remote host

Posted by Zohar <da...@hotmail.com>.
What's the easiest way to transfer all the data from the Request to the 
PostMethod?

----- Original Message ----- 
From: "Avi Deitcher" <av...@deitcher.net>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, July 11, 2006 14:38
Subject: Re: forwarding to a remote host


> Zohar,
> - In the same host & context, use RequestDispatcher.forward()
> - In the same host but different context, if cross-context enabled, get
> the RequestDispatcher for that context then use forward()
> - Different host entirely, or cross-context not enabled, you will
> probably need to rebuild the request. I usually use the Jakarta Commons
> HTTPClient for this. Check out 
> http://jakarta.apache.org/commons/httpclient/
>
> Anyone have a better suggestion?
>
> Avi
>
> Zohar wrote:
>
>>Hello list,
>>I have a servlet that handles POST requests. Sometimes the request needs 
>>to be forwarded to a different servlet, which may be running on a 
>>different server. What is the best way to do that?
>>Thanks,
>>Zohar.
>>
>>
>
> -- 
> ______________________________
> Avi Deitcher
> avi@deitcher.net
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 

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


Re: forwarding to a remote host

Posted by Avi Deitcher <av...@deitcher.net>.
Yeah, that is a good point. The third option - cross context disabled or
remote host - will not keep session data, unless you one of three things:
- the request is stateless (where it doesn't matter anyways)
- you forward everything to the remote host, including the cookies and
all; this seems complex to get right
- you maintain a new session with state locally

I was working under the assumption that a lone request to a remote host
is fully stateless. Not necessarily a fair assumption, I guess.

Pid wrote:

>not unless you've got clustering setup and the cluster is correctly
>sharing session data.  the session data is otherwise local to the server
>in use.
>
>Vinu Varghese wrote:
>  
>
>>Avi,
>>What will happen with the session and objects bound to it ?, Will they
>>be accessible in the second server ?
>>
>>- Regards
>>Vinu
>>
>>Avi Deitcher wrote:
>>    
>>
>>>Zohar,
>>>- In the same host & context, use RequestDispatcher.forward()
>>>- In the same host but different context, if cross-context enabled, get
>>>the RequestDispatcher for that context then use forward()
>>>- Different host entirely, or cross-context not enabled, you will
>>>probably need to rebuild the request. I usually use the Jakarta Commons
>>>HTTPClient for this. Check out
>>>http://jakarta.apache.org/commons/httpclient/
>>>
>>>Anyone have a better suggestion?
>>>
>>>Avi
>>>
>>>Zohar wrote:
>>>
>>> 
>>>      
>>>
>>>>Hello list,
>>>>I have a servlet that handles POST requests. Sometimes the request
>>>>needs to be forwarded to a different servlet, which may be running on
>>>>a different server. What is the best way to do that?
>>>>Thanks,
>>>>Zohar.
>>>> 
>>>>
>>>>    
>>>>        
>>>>
>>>  
>>>      
>>>
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>  
>

-- 
______________________________
Avi Deitcher
avi@deitcher.net



Re: forwarding to a remote host

Posted by Pid <p...@pidster.com>.
not unless you've got clustering setup and the cluster is correctly
sharing session data.  the session data is otherwise local to the server
in use.

Vinu Varghese wrote:
> Avi,
> What will happen with the session and objects bound to it ?, Will they
> be accessible in the second server ?
> 
> - Regards
> Vinu
> 
> Avi Deitcher wrote:
>> Zohar,
>> - In the same host & context, use RequestDispatcher.forward()
>> - In the same host but different context, if cross-context enabled, get
>> the RequestDispatcher for that context then use forward()
>> - Different host entirely, or cross-context not enabled, you will
>> probably need to rebuild the request. I usually use the Jakarta Commons
>> HTTPClient for this. Check out
>> http://jakarta.apache.org/commons/httpclient/
>>
>> Anyone have a better suggestion?
>>
>> Avi
>>
>> Zohar wrote:
>>
>>  
>>> Hello list,
>>> I have a servlet that handles POST requests. Sometimes the request
>>> needs to be forwarded to a different servlet, which may be running on
>>> a different server. What is the best way to do that?
>>> Thanks,
>>> Zohar.
>>>  
>>>
>>>     
>>
>>   
> 

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


Re: forwarding to a remote host

Posted by Vinu Varghese <vi...@x-minds.org>.
Avi,
What will happen with the session and objects bound to it ?, Will they 
be accessible in the second server ?

- Regards
Vinu

Avi Deitcher wrote:
> Zohar,
> - In the same host & context, use RequestDispatcher.forward()
> - In the same host but different context, if cross-context enabled, get
> the RequestDispatcher for that context then use forward()
> - Different host entirely, or cross-context not enabled, you will
> probably need to rebuild the request. I usually use the Jakarta Commons
> HTTPClient for this. Check out http://jakarta.apache.org/commons/httpclient/
>
> Anyone have a better suggestion?
>
> Avi
>
> Zohar wrote:
>
>   
>> Hello list,
>> I have a servlet that handles POST requests. Sometimes the request needs to be forwarded to a different servlet, which may be running on a different server. What is the best way to do that?
>> Thanks,
>> Zohar.
>>  
>>
>>     
>
>   

-- 
........................................

Vinu Varghese
vinu@x-minds.org
www.x-minds.org


Re: forwarding to a remote host

Posted by Avi Deitcher <av...@deitcher.net>.
Zohar,
- In the same host & context, use RequestDispatcher.forward()
- In the same host but different context, if cross-context enabled, get
the RequestDispatcher for that context then use forward()
- Different host entirely, or cross-context not enabled, you will
probably need to rebuild the request. I usually use the Jakarta Commons
HTTPClient for this. Check out http://jakarta.apache.org/commons/httpclient/

Anyone have a better suggestion?

Avi

Zohar wrote:

>Hello list,
>I have a servlet that handles POST requests. Sometimes the request needs to be forwarded to a different servlet, which may be running on a different server. What is the best way to do that?
>Thanks,
>Zohar.
>  
>

-- 
______________________________
Avi Deitcher
avi@deitcher.net



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