I've got a similar problem using Apache and JServ.
When I compile some classes "over" the old ones and call them on the server,
the engine always starts a new thread.
I assume that the engine opens some kind of new object environment, because
even global object have to be allocated again.
Is this an error...??

> -----Urspr�ngliche Nachricht-----
> Von:  DeSarro Frank [SMTP:[EMAIL PROTECTED]]
> Gesendet am:  Mittwoch, 14. Juli 1999 18:36
> An:   [EMAIL PROTECTED]
> Betreff:      Multiple servlets and a shared class
>
>         This is probably a foolish question, but I have spent so much time
> trying to figure it out with little to show for it that I have to try
> something.  I'm new to servlets, but I've read Hunter's servlet book.
>  I'm working with Websphere Application Server.  I have two servlets A &
> B.  There is a separate shared class, call it C that A & B use.
>  Everything works as I expect it to.  The problem is that if I change
> servlet B and place it on the server, when the newly loaded servlet B
> tries to use class C it throws a ClassNot Found exception.  Is my
> thinking wrong?  If C has not changed, I should not have to unload A
> because of a change in B.  The only way I can get it to work is to unload
> A&B twice and then it works.  This might be a dumb question, but I can't
> seem to figure out what is happening.  If my logic is sound, then I know
> I have to focus on my code.  If anyone can share any thoughts or even
> point me to an article or book that would explain how this is supposed to
> work I would appreciate it.  Thanks.
>
If you are using a shared class then you are going to have severe problems
when it comes to
accessing this class because how are you certain which servlet is loaded
first?
Not only that but if you are dependent on servlet loading order then you
will have to repeat
the loading sequence when anything changes in any of the three objects. They
to your problem
lies in the state of the 2 servlets. They are dependent on each other so
when one changes the state
of both changes, resulting in you having to unload both servlets in order to
have the thing work.
There are sensible precautions which can nullify this of course (sharing
objects via requests when chaining,
using session objects, marshalling (using a servlet as a broker for shared
objects) and so on.

Remember, web serving is stateless. When your servlets become dependent on
state information then
keep that information somewhere outside of the servlet so that the dependent
servlet can retrieve that
on demand (as I said, session object, passing objects via request objects
when chaining or use
a broker) and then discard that information when it no longer needs it
(usually at the end of a request OR
at the end of the servlet lifetime (ie dispose of it in destroy() method)

Hope this all helps

Andy Bailey

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to