aspose file tools*
The moose likes Tomcat and the fly likes servlet not reloading on Tomcat 4.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "servlet not reloading on Tomcat 4.0" Watch "servlet not reloading on Tomcat 4.0" New topic
Author

servlet not reloading on Tomcat 4.0

Shuaib Gill
Ranch Hand

Joined: May 29, 2001
Posts: 62
I wrote a simple Hello World servlet , compiled it and had it working on the web browser, so far so good. Next I changed the servlet, recompiled it and clicked on the Refresh button on the browser, nothing, no change.
I have to shut down and restart the standalone Tomcat Apache engine each time I recompile the servlet, it is very tedious.
Someone please help.


programmer77
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I've closed the previous thread, but for the future, either start a new thread right away if you are talking about a new problem, or just stick with the old one.

for reference: http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=56&t=000205
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I am using:
Tomcat 4.0.1
Windows 2000 Pro, SP2
IE 5.5

Here is my directory structure:

In server.xml, the only addition I've made is a test Context element between the manager context and the examples context:

In my web.xml under my webapp's WEB-INF directory, I have: Finally, my servlet code is:
Starting Tomcat, and hitting the URL: http://localhost:8080/test/hello produces a page titled "Hello World!" with "Hello World!" in Big letters.

Going back to my servlet, and uncommenting the Small Change line, recompiling, and refreshing my browser, and I see a different page.. one that has "Small Change" right underneath Hello World.

The very first time I did this, I had to hold down the Shift key while I clicked on Refresh. For each subsequent change, (I put on "change 2, change 3, etc, etc...), a single click on the refresh seemed to work.

There are no 'special' considerations to be made. Just make sure you have the 'reloadable' attribute in your Context element set to true, and you should be fine. I had previously thought this was a default value, but I've tried it out, and it doesn't appear to work.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I've played around some more...

SOMETIMES, it will work if you use *just* the DefaultContext element, with reloadable=true. Other times, it will not.
SOMETIMES, it will work with the DefaultContext, with reloadable=true, AND a test Context (missing a reloadable attribute). Other times it will not, or is SLOW to recognize the change.

BUT... I cannot get it to behave badly if I have the reloadable=true set into the test context. So I think the bottom line here is, make sure you make a context for each webapp, and explicity set it's reloadable attribute = true. Don't rely on the automatic DefaultContext (or even the automatic 'creation' of contexts from directory structures in webapps).

And after all that, I'm sure other people have different experiences using Tomcat on their machines. Oh, the joy of software development.
[ February 14, 2002: Message edited by: Mike Curwen ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet not reloading on Tomcat 4.0