• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Getting Response Back in calling Servlet

 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have an following requirement

1 Browser makes an request to Servlet in Sever1
2 Servlet in Server1 will make an HTTP post request to Servlet in
server2 with one paramter called reqData which will be an xml
format data as follows
<emp>
<emp-no>10</emp-no>
<emp-name>Bond</emp-name>
</emp>

3 Now Servlet on server2 will read this data and send back the response
in xml format as
<response>
<response-code>0</response-code>
...
...
...
</response>

I am clear till read reqData and generate response Data (3).

but how do I get response data back in servlet on server1 and display the result on browser ?

I guess I need to use some way to call servlet in sever2 other then simply using sendRedirect.

kindly help

Cheers
-Praful
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

2 Servlet in Server1 will make an HTTP post request to Servlet in
server2


If you make a POST request to server2 with a HttpURLConnection, you will get the results back in the response. You can read the response headers and get the response body with separate methods. The headers will probably have useful information and the stream representing the body will have the xml.
Look at the methods in java.net.URLConnection and HttpURLConnection.
Bill
 
Praful Thakare
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi William,
Thanx A bunch for your reply will go thru both classes(interfaces)

Cheers
-Praful
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic