GeeCON Prague 2014*
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
Author

Calling Servlets in different Web applications?

Karthi Bala
Ranch Hand

Joined: Jul 27, 2001
Posts: 48
Hi,
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?
Thanks


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: 16093
    
  21

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.
 
GeeCON Prague 2014
 
subject: Calling Servlets in different Web applications?