Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending HTTP POST from Server to another Server

 
Sahil Reddy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2745
38
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The HttpClient library (or even just the HttpURLConnection class) can do this.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic