aspose file tools*
The moose likes Servlets and the fly likes Sending HTTP POST from Server to another Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sending HTTP POST from Server to another Server" Watch "Sending HTTP POST from Server to another Server" New topic
Author

Sending HTTP POST from Server to another Server

Sahil Reddy
Ranch Hand

Joined: Jan 24, 2011
Posts: 145
Hello Geeks


I am new to Servlet world... I have the requirement to send the HTTP Post from the Server to another server with the same request and response object i am getting in doPost method. Please let me
know how can i achieve the same..


Client---->(HTTP POST)---->Server 1-----.(HTTP POST)---->Server 2

I want to achieve step 2 i.e. Sending same HTTP POST request from Server 1 to Server 2.

Regards
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
The HttpClient library (or even just the HttpURLConnection class) can do this.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12789
    
    5
Now wait a minute!

The request and response objects are created and managed by the servlet container, you can't just ship them around to another server.

The content of the HTTP POST body, sure, but the request and response belong to the initial servlet.

Bill

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61232
    
  66

Sahil Reddy wrote:send the HTTP Post from the Server to another server with the same request and response object

As William pointed out, this is impossible, with HttpClient or otherwise.

What are you really trying to achieve?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending HTTP POST from Server to another Server