JSP Tutorials - Herong's Tutorial Examples - v5.11, by Herong Yang
Refreshing Loaded JavaBean Classes
This section provides a tutorial example on how to refresh loaded JavaBean classes using the 'Reload' function on the Tomcat Application Manager.
Once a JavaBean class has been used once by a JSP page, it will stay loaded in memory to avoid loading it again when another JSP page uses it. This is good to improve response time, but it is a problem if you changed your JavaBean and wants to push the newer version into the server.
One way to force the server to use the new versions of JavaBean classes is to shut down the server and re-start the server.
But a better way to force the server to use the new versions is to use the Tomcat Manger tool. Here is how to do this:
1. Set up a manager user name and password by adding the following line to \local\tomcat\conf\tomcat-users.xml:
<role rolename="manager-gui"/> <user username="herong" password="s3cret" roles="manager-gui"/>
2. Shut down and re-start Tomcat server.
3. Visit UseBean.jspx with a Web browser.
4. Modify CacheBean.java, compile it, and copy the class file to \local\tomcat\webapps\ROOT\WEB-INF\classes\herong.
5. Go to http://localhost:8080/manager/ with IE and enter user name and password created in step 1.
6. Click the "Reload" button for the default application "/".
7. Visit UseBean.jspx again. You should see the changes made to CacheBean.java in step 4.
Table of Contents