Home TOC |
![]() ![]() ![]() |
Updating Web Applications
During development, you will often need to make changes to Web applications. After you modify a servlet, you must
When you update a JSP page, you do not need to recompile or reload the application, because Tomcat does this automatically.
To try this feature, modify the servlet version of the Hello application. For example, you could change the greeting returned by
GreetingServlet
to be:<h2>Hi, my name is Duke. What's yours?</h2>
- Edit
GreetingServlet.java
in the source directorydocs/tutorial/examples/hello1/src/
.- Run
ant build
. This task recompiles the servlet into thebuild
directory.The procedure for updating the application in the server depends on whether you installed it using the
Ant
install
task or deployed it usingdeploytool
.Reloading Web Applications
If you have installed an application using the
Ant
install
command, you update the application in the server using theAnt
reload
task:<reload url="url" path="path" username="username" password="password" />The example build files contain an
Ant
remove
target that invokes theAnt
remove
task. Thus to update theHello1
application in the server, executeant
reload
. To view the updated application, reload theHello1
URL in the client. Note that thereload
task only picks up changes to Java classes, not changes to theweb.xml
file. To reloadweb.xml
, remove the application (see Removing Web Applications) and install it again.You should see the screen in Figure 12-3 in the browser:
To try this on the JSP version of the example, first build and deploy the JSP version of the Hello application:
- In a terminal window, go to
docs/tutorial/examples/hello2.
- Run
ant
build
. Thebuild
target will spawn any necessary compilations and copy files to thedocs/tutorial/examples/web/hello2/build
directory.- Run
ant
install
. Theinstall
target copies the build directory to<JWSDP_HOME>
/webapps
and notifies Tomcat that the new application is available.Modify one of the JSP files. Then run
ant
build
to copy the modified file intodocs/tutorial/examples/web/hello2/build
. Remember, you don't have to reload the application in the server, because Tomcat automatically detects when a JSP page has been modified. To view the modified application, reload theHello2
URL in the client.Redeploying Web Applications
If you have deployed a Web application using
deploytool
, you must update it usingdeploytool
as follows:
- Select the
hello1
WAR.- Select Tools
Update Files.
- A dialog will appear listing the changed file. Verify that it is
GreetingServlet.class
and click OK twice.- Select Tools
Update and Redeploy.
- A dialog will appear. Select
/hello1
from the Select Webapp to redeploy combo box and click OK.- Dismiss the Redeploy Console by clicking Close.
Home TOC |
![]() ![]() ![]() |