Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

calling one servlet from another servlet in separate JVM's

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

We have 2 separate tomcat instances running on different physical servers. I want to call servlet A on server 1 from servlet b on server 2.

Please help. I need to pass the same request and response parameters which i have recived in servlet b. i.e. I want to forward a request . I guess the requestdispatcher will not work as it's different jvm and web.xml.

Regards,
Dev
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to make an HTTP request to the remote servlet.

You can use the classes in the java.net package, or use a higher-level API such as HttpClient.
 
Dev Lakhani
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You'll need to make an HTTP request to the remote servlet.

You can use the classes in the java.net package, or use a higher-level API such as HttpClient.




Thanks for the response. How do I set the same httpRequest and HttpResponse when i call the other servlet using apache HTTPClient. I need to forward the request.

Regards,
Dev
 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dev Lakhani wrote:How do I set the same httpRequest and HttpResponse when i call the other servlet using apache HTTPClient. I need to forward the request.


You don't, and you can't. You need to make a separate request tot he remote server.
 
Dev Lakhani
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Dev Lakhani wrote:How do I set the same httpRequest and HttpResponse when i call the other servlet using apache HTTPClient. I need to forward the request.


You don't, and you can't. You need to make a separate request tot he remote server.



Ok, But the HttpRequest which I get has a lot of information in it. I recieve it in via doPost. I want to send all that info as it is to the other servlet. Please help. Thanks.
 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create a post request with the same body.
 
Dev Lakhani
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Create a post request with the same body.



Ok thanks, but how to create a post request with the same body using HttpClient. Please help

regards,
Dev
 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's time for you to look at the API you intend to use and figure out how to make a POST with it.

No one is being paid here to write your code for you.
 
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic