• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlet communication on different servers.

 
Greenhorn
Posts: 25
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

Greetings !! hope you all doing great with your kith and kin.

I have a new problem(not actually a problem but something new to learn about ) ,i am doing some manipulations with one servlet ,say

ServletOne, now i have ServletTwo on different tomcat server.

now i want to send a request from ServletOne to ServletTwo and want a response back from ServletTwo to ServletOne.

what is best way to achieve it. I am using URL CLass for this.but i want to send response back from ServletTwo to ServletOne with some values. will sendRedirect will help in this,in case i need some values with it.

Please suggest.

Thanks
 
Greenhorn
Posts: 13
Oracle Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried to use RequestDispatcher#include?
 
Ranch Hand
Posts: 81
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for interservercommunications on this level, i use the HttpURLConnection.

for writing use *.getOutputStream();

for getting the response, use *.getInputStream()

for example, you can send an xml, and receive an answer, also as xml.

Search for the specifications of this one, you'll find it!
 
satnam singh negi
Greenhorn
Posts: 25
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

olivier dutranoit wrote:for interservercommunications on this level, i use the HttpURLConnection.

for writing use *.getOutputStream();

for getting the response, use *.getInputStream()

for example, you can send an xml, and receive an answer, also as xml.

Search for the specifications of this one, you'll find it!




can you please share some piece of code for better understanding. this would be great help.

Thanks in advance
 
olivier dutranoit
Ranch Hand
Posts: 81
IBM DB2 Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is a quick and dirty example :

 
satnam singh negi
Greenhorn
Posts: 25
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

olivier dutranoit wrote:here is a quick and dirty example :



Thank you so much for quick responses,
The problem is that we are trying to implement browser re-direction without a browser, which is not a good idea. In order to invoke the servletTwo on other server , we need to work with help of browser redirections at this phase.

Its like there are three different server, server1 is requestor server from where all the incoming request will come to server2 which is the main server where all the request validations are taken care of. my situation is while validating that request means in between the code i need to reach to server 3 ,collect the response from there and again return to server 1.

this is the whole scenario. how can implement browser redirection in between java code.

Please suggest, and moreover thanks for the time to read the post.

cheers.

 
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic