my dog learned polymorphism*
The moose likes Servlets and the fly likes How to get tomcat to use the newest version of a servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get tomcat to use the newest version of a servlet?" Watch "How to get tomcat to use the newest version of a servlet?" New topic
Author

How to get tomcat to use the newest version of a servlet?

eileen keeney
Ranch Hand

Joined: May 04, 2009
Posts: 51
Problem, when I change the code in the .java file, and recompile using javac to a new .class file, my browser still runs the old class code.

I am using tomcat, creating the code by editing a .java file, and compiling using javac into a .class file.
There is an associated web.xml file.

So far I have been told the following, related to how to solve the problem:
- Clear Browser Cache.
done, problem not on client side. I have tested this.
- Use a war file, because tomcat will accept the updates when exploding a war file.
I might do this later in the project, but not at this point in development
- restart the tomcat server.

Since iterative coding, where one runs the code to test what is there, followed by changes, and running the code again, is such a common practice, I find it hard to believe that there is not a much easier way to test changes.
Maybe some setting in tomcat?

Right now I either have to restart the tomcat process or test by renaming the class each time I change the code (which is tedious).

Any ideas?
I am pretty certain it is a server side (not client side) issue, possibly tomcat cache.

The server is running hpux 11.2
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

download the tomcat6.0 to use recent servlet version
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41631
    
  55
Welcome to JavaRanch.

Indeed, this is a server setting; it has nothing to do with browser caching.

Restarting Tomcat is generally not required - restarting the web app is sufficient. It can be done with the Tomcat manager web app, and is much faster than restarting Tomcat itself.

You can also have Tomcat monitor your class files, and have it restart the web app automatically. That's governed by the "reloadable" attribute of the "Context" element in the configuration; see http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

seetharaman venkatasamy wrote:download the tomcat6.0 to use recent servlet version

Eileen is asking about a more recent version of the servlet, not a more recent version of the servlet specification.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get tomcat to use the newest version of a servlet?