|
Home
TOC Index |
|
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
GreetingServletto be:<h2>Hi, my name is Duke. What's yours?</h2>
- Edit
GreetingServlet.javain the source directory<JWSDP_HOME>/docs/tutorial/examples/web/hello1/src.- Run
ant build. This task recompiles the servlet into thebuilddirectory.The procedure for updating the application in the server depends on whether you installed it using the
Antinstalltask or deployed it using theAntdeploytask ordeploytool.Reloading Web Applications
If you have installed an application using the
Antinstallcommand, you update the application in the server using theAntreloadtask:<reload url="url" path="mywebapp" username="username" password="password" />The example build files contain an
Antremovetarget that invokes theAntremovetask. Thus to update theHello1application in the server, executeantreload. To view the updated application, reload theHello1URL in the client. Note that thereloadtask only picks up changes to Java classes, not changes to theweb.xmlfile. To reloadweb.xml, remove the application (see Removing Web Applications) and install it again.You should see the screen in Figure 4-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
<JWSDP_HOME>/docs/tutorial/examples/web/hello2.- Run
antbuild. Thebuildtarget will spawn any necessary compilations and copy files to the<JWSDP_HOME>/docs/tutorial/examples/web/hello2/builddirectory.- Run
antinstall. Theinstalltarget copies the build directory to<JWSDP_HOME>/webappsand notifies Tomcat that the new application is available.Modify one of the JSP files. Then run
antbuildto 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 theHello2URL in the client.Redeploying Web Applications
If you have deployed a Web application
deploytool, you update it usingdeploytoolas follows:
- Select the
hello1WAR.- Select Tools
Update Files.
- A dialog will appear listing the changed file. Verify that it is
GreetingServlet.classand click OK twice.- Select Tools
Update and Redeploy.
- A dialog will appear. Select
/hello1from the Select Webapp to redeploy combo box and click OK.- Dismiss the Redeploy Console by clicking Close.
If you have deployed the application using the
Antdeploytask you update the application by using theAntundeploytask (see Undeploying Web Applications) and then using theAntdeploytask.
|
Home
TOC Index |
|
This tutorial contains information on the 1.0 version of the Java Web Services Developer Pack.
All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.