Refreshing Loaded JavaBean Classes

This section provides a tutorial example on how to refresh loaded JavaBean classes using the 'Reload' function on the Tomcat 7 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 C:\local\apache-tomcat-7.0.32\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 IE.

4. Modify CacheBean.java, compile it, and copy the class file to C:\local\apache-tomcat-7.0.32\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.

Last update: 2012.

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat 7 Installation on Windows Systems

 JSP Scripting Elements

 Java Servlet Introduction

 JSP Implicit Objects

 Syntax of JSP Pages and JSP Documents

 JSP Application Session

 Managing Cookies in JSP Pages

JavaBean Objects and "useBean" Action Elements

 What Is a JavaBean?

 "jsp:useBean" Action Elements

 Servlet Class Converted from UseBean.jspx

 Setting and Getting JavaBean's Properties

 Using JavaBean Objects in Scripting Elements

 Using Java Objects as JavaBeans

 getProperty() Error on Tomcat 7

Refreshing Loaded JavaBean Classes

 Importing Unnamed Package Class Error

 Using JavaBean without Import Element Error

 Creating JavaBean Classes in Named Packages

 "NoClassDefFoundError" Exception

 Managing HTTP Response Header Lines

 Non-ASCII Characters Support in JSP Pages

 Performance of JSP Pages

 EL (Expression Language)

 Overview of JSTL (JSP Standard Tag Libraries)

 JSTL Core Library

 JSP Custom Tags

 JSP Java Tag Interface

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

 Outdated Tutorials

 References

 PDF Printing Version