wood burning stoves 2.0*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing data between 2 servlets across applications" Watch "Passing data between 2 servlets across applications" New topic

Passing data between 2 servlets across applications

Balaji Kameswaran

Joined: Feb 19, 2003
Posts: 1
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");
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.
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
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!
[ February 20, 2003: Message edited by: christoph weingarten ]
[ February 20, 2003: Message edited by: christoph weingarten ]
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12761
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Passing data between 2 servlets across applications
Similar Threads
Help needed! regarding Global Security settings and Virtual hosts
how to setup separate ports for web applications
Aleksander's Clarification needed
Setting up web sites
****ServletContext and WebApplication confusion****