Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing data between 2 servlets across applications

 
Balaji Kameswaran
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ugh! I have the same question too!
 
christoph weingarten
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic