Persistent servlets & inter-servlet communication

A

atrauzzi

Just curious to know if there is a way to have a servlet that is not
destroyed at the end of it's request?

Also, is there any way I can get a reference to an instance of a
servlet from somewhere else on the same application server?

(Assuming Sun App Server 9.0)
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Just curious to know if there is a way to have a servlet that is not
destroyed at the end of it's request?

A normal servlet is not destroyed at end of request. It is
one object being used by multiple threads.

If you implement SingleThreadModel then you get the behaviour you
describe.
Also, is there any way I can get a reference to an instance of a
servlet from somewhere else on the same application server?

(Assuming Sun App Server 9.0)

You don't. You redesign so you do not need it.

(if you really want to then I think you can have
the servlet itself save this somewhere where you can get it)

Arne
 
M

Manish Pandit

Hi There,

AFAIK, a servlet does not get destroyed at the end of a request. The
container re-uses a servlet instance (1 and only 1, unless you're
refering to the SingleThreadModel) to "service" the requests in
multiple threads. Could you elaborate on what you are trying to
achieve, and possibly, why you need something like this. Also, since
the container manages the lifecycle of a servlet, you should avoid
situations where you want to get a hold of a servlet instance and
invoke its methods.

-cheers,
Manish
 
A

atrauzzi

These are all good explanations towards all my questions. Thank you.

I just want to have something running server-side that watches and acts
upon messages on a topic via JMS.

On that note, do any of you know of some DECENT JMS tutorials? Front
to back? Even sun's "Java EE 5 Tutorial" does a spotty job on
explaining how one can make a JMS application. All the examples seem
to omit something.

I know exactly how I want to structure this, I just have a difficult
time pulling out the correct understanding of all the seemingly
appropriate Java components to get the job done :D

Thanks again!

- Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top