Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forward or Redirect http request to a web application on different web container/JVM with some param

 
Raj Arya
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm inside web application A. I want to send request to a web application B which is running in different container/different JVM with some parameter. How could I do so.
Will Request Dispatcher would work? or Is there any other way to do so. Please help!!

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just add the parameters to the URL. For example /other/app?a=1&b=2.

Also, please check your private messages.
 
Gaurav Sagar
Ranch Hand
Posts: 97
Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A RequestDispatcher is only for in the intra application communication and would not work for things outside the web application. The only thing you may do is to use the GET request for the inter communication between the two web applications.

Regards,
Gaurav
 
Raj Arya
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jeanne & Gaurav
Thanks for your reply. But adding parameters to the URL doesn't work. the moment I try to submit request for web app outside the container; I loose the data.
 
Chinna Eranna
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
test now wrote:
I'm inside web application A. I want to send request to a web application B which is running in different container/different JVM with some parameter.


For what reason you are sending a request from A to B application. Do you want to use the response of "B" for building response in "A" or user will be redirected to application "B" ?
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Test now..
Welcome to JavaRanch..
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using the doGet() method originally to reach the servlet then the method that is used by requestdispatcher to pass the request to different application will be doGet() only.

So that may be the reason your request dispatcher is not working and when you add parameters to the URL you loose the data.

So try it using doPost(),

It should forward the request with additional parameters to other application.

 
Raj Arya
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Chinna
Actually Whenever user comes to Application A, I'm doing some preprocessing of user data in Application A and then I want to send some encripted information to application B which is in different container.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"test now", please check your private messages for an important administrative matter. Do it now. Thanks.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you want to send the secure data so make sure to use

<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>


in web.xml
 
Rudy Gireyev
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj could HttpURLConnection be what you are looking for?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic