I'm probably misinterpreting what I'm seeing, but when using Jakarta/
Tomcat v2.2 the changed class isn't being reloaded.

I'm changing the HTML that gets displayed from "Parameter" to
"1Parameter" just to test the reloading aspect. And the web page
being displayed doesn't change.

Since the .java files that I'm using are so small, I've attached them
to this note.

The HelloWorldExample displays a simple form. When parameters are
entered and a transaction is selected, the form calls the
dispatch routine (doPost) which loads the request transacation
class.

Here are the steps that I'm using to test:

I select transcation one, see "Parameter" in the resulting page. Then
hit the back button to return to the form.

I edit TRN1.java changing to "1Parameter". And recomplile.

I reselect the first transaction and the resulting page still shows
"Parameter". This leads me to the conclution that the new .class
file hasn't been loaded.



jon * wrote:
> on 11/22/99 10:50 AM, David Medinets <[EMAIL PROTECTED]> wrote:
> > Hi. I'm using the following line of code to dynamically load
> > classes as needed by my servlet:
> >
> > // Determine which class to instantiate.
> > TransClass = (Class.forName(req.getParameter("transaction")));
> >
> > I'd like the class to be reloaded when the .class file changes. I've
> > read that you can't unload a class, you can only create a new class
> > loader each time the .class file changes.
> >
>
> In this case, your code will get reloaded properly since you are getting a
> newInstance() each time. This is the #1 principle that Turbine is based on.
>
> <http://java.apache.org/turbine/>
>
> In fact, with Turbine you have the option to cache those instances in a
> Hashtable so that they are only loaded once or loaded each time.
</BODY></HTML>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<title>Servlet Demonstration Driver Page</title>
</head>
<body bgcolor='#FFFFFF'>

HelloWorldExample.java

TRN1.java

        <H1>Java Servlet Demonstration</H1><p>
        To execute servlet: type in parameters, select a transaction, then click the 
"Issue Request" button.<p>
        <FORM METHOD=POST ACTION='/examples/servlet/HelloWorldExample'>
        <b>Parameter One:</b>&nbsp<INPUT TYPE=TEXT NAME="parm1"><p>
        <b>Parameter Two:</b>&nbsp<INPUT TYPE=TEXT NAME="parm2"><p>
        <b>Parameter Three:</b>&nbsp<INPUT TYPE=TEXT NAME="parm3"><p>
        <b>Transaction:</b><nbsp>
        <SELECT NAME="transaction">
        <OPTION Value="TRN1">Transaction One
        <OPTION Value="TRN2">Transaction Two
        <OPTION Value="TRN3">Transaction Three
        </SELECT>
        <p>
        <INPUT TYPE=SUBMIT VALUE='Issue Request'>
        </FORM>

Reply via email to