my dog learned polymorphism*
The moose likes Servlets and the fly likes Calling Servlets in different Web applications? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Calling Servlets in different Web applications?" Watch "Calling Servlets in different Web applications?" New topic

Calling Servlets in different Web applications?

Karthi Bala
Ranch Hand

Joined: Jul 27, 2001
Posts: 48
Can I call a method in a servlet which is instantiated in a web application from another servlet which is in different web application.
I don't want the instantiate the servlet again?

Karthi Bala<br />SCJP 1.2, SCWCD 1.3, SCWCD 1.4, SCDJWS (Awaiting Result)<br /> <br />Where there is a will,there is a WAY.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15956

I wouldn't recommend it. You can get into all sorts of trouble - the servlets may someday end up in separate VMs, so it would be physically impossible. Even if not, this is a dangerous way to organize things, as you're creating non-obvious dependencies both on data and on thread processes.
It would be safer if you could extract the common functionality into a component in its own right. For simple cases, this might just be a library class. If there's more complexity or shared data, I'd recommend looking at Enterprise JavaBeans.

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: Calling Servlets in different Web applications?
Similar Threads
importing a package which is in different application
Part 2 design question
is it possible to distribute a servlet based application?
Accessing servlet
Servlet container - what is the real definition?