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

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
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: 17142

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: Calling Servlets in different Web applications?
It's not a secret anymore!