This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Forward or Redirect http request to a web application on different web container/JVM with some param Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Forward or Redirect http request to a web application on different web container/JVM with some param" Watch "Forward or Redirect http request to a web application on different web container/JVM with some param" New topic
Author

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

Raj Arya
Greenhorn

Joined: May 24, 2011
Posts: 3
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Just add the parameters to the URL. For example /other/app?a=1&b=2.

Also, please check your private messages.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Gaurav Sagar
Ranch Hand

Joined: Sep 08, 2010
Posts: 97

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

Joined: May 24, 2011
Posts: 3
@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

Joined: Dec 08, 2009
Posts: 174

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" ?


- Chinna
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

@Test now..
Welcome to JavaRanch..


SCJP6.0,My blog Ranchers from Delhi
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

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

Joined: May 24, 2011
Posts: 3
@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

Joined: Jan 10, 2002
Posts: 60822
    
  65

"test now", please check your private messages for an important administrative matter. Do it now. Thanks.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

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

Joined: May 03, 2011
Posts: 39
Raj could HttpURLConnection be what you are looking for?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Forward or Redirect http request to a web application on different web container/JVM with some param
 
Similar Threads
Application deployed at two servers or containers
Web Container
Calling web container from jacl command
question on servlet contexts
DB calls from Servlet Filter vs Action class