• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

Java Object

Hi

How can I get a reference to an object( already instantiated) from different java codes?

Well I am trying to develop a Web application where in the "mainclass -method to access backend", is instantiated once, during server startup.
Now I want to get a reference of it so that I can call any of its method in any Servlet or JSP or a jhtml?

IS RMI the only way, or is there a simpler way?

Thanks
W
0
W122498
Asked:
W122498
1 Solution
 
mmarschallCommented:
The only way as far as I know is RMI.

With Servlet API 2.0 it was possible to directly connect to an other servlet. We did this to get this "mainclass" feature. But starting with Servlet API 2.1 this possiblity is not given any longer.
One way to do it may be to use one servlet as "mainclass" an forward any request, which has to be processed by the "mainclass" to this servlet. Then forward the answer to either an servlet or an jsp. But this may be imperformant.

Hope this helps,

matthias
0
 
jjdunneCommented:
CORBA would be an alternate solution.  I don't think it would be much easier since you will have to deal with things like firewalls.
0
 
W122498Author Commented:
Thanks
I think RMI would be a better alternative to CORBA
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now