Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes Passing data between 2 servlets across applications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing data between 2 servlets across applications" Watch "Passing data between 2 servlets across applications" New topic
Author

Passing data between 2 servlets across applications

Balaji Kameswaran
Greenhorn

Joined: Feb 19, 2003
Posts: 1
Hi,
I am new to this forum. My requirment is to pass data between 2 servlets which are in different applications. Eg.
Application Servlet context root
---------------------------------------
One first /firstone
Second second /secondtwo
Let us assume I am in "first" servlet and needs to pass the data to second servlet. Both the apps are in the same virtual host, but different Application Servers. IBM InfoCenter says, as long as these applications are under the same virtual host, you can get the ServletContext of second app and use setAttributes. The sample code given by IBM is :
appBcontext = appAcontext.getContext("/appB");
appBcontext.getRequestDispatcher("/servlet5");
But, I don't understand this code. My main problem is, given the above examples, how can I change the code ?
Thanks for your reply.
Balaji
qingwu wang
Ranch Hand

Joined: Feb 19, 2003
Posts: 147
ugh! I have the same question too!


Thanks...qingwu<br />When I open my eyes,I see your pretty face.
christoph weingarten
Ranch Hand

Joined: Oct 10, 2002
Posts: 39
hi,
I'am not sure. but it seems, that your are using an applicationContext (or something else) in your exampleCode.
you can get your servletContext this way:

but be carefull with this! as far as i know, ALL servlets in a servletcontainer are using the SAME servletContext!
ragards
christoph
[ February 20, 2003: Message edited by: christoph weingarten ]
[ February 20, 2003: Message edited by: christoph weingarten ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
According to the latest Servlet/JSP API, there is one ServletContext per Web Application per JVM. This information is readily available in the javax.servlet.ServletContext JavaDocs.
The whole idea of a "Web Application" is to ensure that you can have multiple web applications being served by a single servlet container with ZERO chance of them interfering with each other or opening security holes.
You can have conversations between applications by opening URLs, just as if they were on separate machines and exchange data that way.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing data between 2 servlets across applications