There may be a miscommunication here.
youngho, when a Class is loaded for the first time into a JVM, using
Class.forName or because another class requires it when that other class is
loaded, the Class is loaded, resolved, and associated forever with the
ClassLoader instance that loaded it. If for some reason that ClassLoader
should "go away", then the Class will need to be reloaded, and any data
stored with that Class is lost forever.
However, so long as that ClassLoader remains in place, subsequent calls to
Class.forName() will reuse the already-loaded class and NOT re-load the
Class from disk. Thus, when you say that "But my problem is whenever the
Class reload , the HT becomes null !. >> I would like to know how can I
reuse a data even after the class reload at >the dynamic class roading
method. "[sic], I'm not entirely sure what you're intending. I believe Andy
has it right, that you need to keep the *instance* of the class around
longer in order to reuse it between invocations, but that has nothing to do
with the *class* being reloaded all the time--the instance could not exist
had the class not been loaded first.
Can you clarify or post some code to demonstrate what you're trying to do?
Ted Neward
Patterns/C++/Java/CORBA/EJB/COM-DCOM spoken here
http://www.javageeks.com/~tneward
"I don't even speak for myself; my wife won't let me." --Me
-----Original Message-----
From: Andy Bailey <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Monday, July 26, 1999 10:05 AM
Subject: Re: How can I reuse a data at the dynamic class roading servlet
>> Hi,
>> I have a question.
>> I use a dynamic class roading mathod using Class.forName method in my
>controll servlet.
>> ( there is only one control servlet and many transaction classes)
>> At the one stage, I got a client requested parameter through getParameter
>method ,
>> pass the parameter to my DB , received some data ( Let's call HT ) from
>DB and return back a part of data to
>> the client. Ath the next stage ( reload a new class ) , if a client
>request a more detail data
>> then I would like to reuse HT.
>> But my problem is whenever the Class reload , the HT becomes null !.
>> I would like to know how can I reuse a data even after the class reload
at
>the dynamic class roading method.
>> Any codelet or suggestions appreciates.
>>
>> Thanks in advance.
>>
>> youngho
>>
>The class reload is not the problem here.
>
>Your data (HT) will be lost between requests unless you can store it in the
>session object.
>
>HT needs to be Serializable for this to work.
>
>You can then do session.putValue("somekey", HT);
>to store it.
>
>HTClass HT = (HTClass)session.getValue("somekey");
>
>gets it back for you.
>
>Hope that 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
___________________________________________________________________________
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