This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet communication across web applications

 
Surya Kant
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have two web applications running in same tomcat container.I want to communicate between two web applications using servlets.
I mean servlet1 in web application1 will call servlet2 in web application2.Is it possible??

And one more doubt is..Is session id will be same in both the web applications?


Regards,
Surya
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If by "communicate" you mean via HTTP, then you can use the HttpURLConnction class to do that. See e135 and e136 in http://www.exampledepot.com/egs/java.net/pkg.html

The session IDs will be different, because sessions are bound to web apps; they can't be shared across web apps.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or else you can also use HTTPClient for this ,

One more solution is that Obtain that ServletContext (The context name of that web application which you have defined in server.xml file) and put cross-context is true .
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can figure out if the reason you need to communicate is because the apps should be one? Or there's code that should be in each app?
 
Vinod K Singh
Ranch Hand
Posts: 198
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RaviNada Kiran wrote:One more solution is that Obtain that ServletContext (The context name of that web application which you have defined in server.xml file) and put cross-context is true .


Cross context stuff may not be portable on other servers.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic