The JavaTM Web Services Tutorial
Home
TOC
Index
PREV TOP NEXT
Divider

Updating Web Applications

During development, you will often need to make changes to Web applications. After you modify a servlet, you must

  1. Recompile the servlet class.
  2. Update the application in the server.
  3. Reload the URL in the client.

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>
 

To update the file:

  1. Edit GreetingServlet.java in the source directory <JWSDP_HOME>/docs/tutorial/examples/web/hello1/src.
  2. Run ant build. This task recompiles the servlet into the build directory.

The procedure for updating the application in the server depends on whether you installed it using the Ant install task or deployed it using the Ant deploy task or deploytool.

Reloading Web Applications

If you have installed an application using the Ant install command, you update the application in the server using the Ant reload task:

<reload url="url" path="mywebapp"
  username="username" password="password" />
 

The example build files contain an Ant remove target that invokes the Ant remove task. Thus to update the Hello1 application in the server, execute ant reload. To view the updated application, reload the Hello1 URL in the client. Note that the reload task only picks up changes to Java classes, not changes to the web.xml file. To reload web.xml, remove the application (see Removing Web Applications) and install it again.

You should see the screen in Figure 4-3 in the browser:

Figure 4-3 New Greeting

To try this on the JSP version of the example, first build and deploy the JSP version of the Hello application:

  1. In a terminal window, go to <JWSDP_HOME>/docs/tutorial/examples/web/hello2.
  2. Run ant build. The build target will spawn any necessary compilations and copy files to the <JWSDP_HOME>/docs/tutorial/examples/web/hello2/build directory.
  3. Run ant install. The install 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 into docs/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 the Hello2 URL in the client.

Redeploying Web Applications

If you have deployed a Web application deploytool, you update it using deploytool as follows:

  1. Select the hello1 WAR.
  2. Select ToolsUpdate Files.
  3. A dialog will appear listing the changed file. Verify that it is GreetingServlet.class and click OK twice.
  4. Select ToolsUpdate and Redeploy.
  5. A dialog will appear. Select /hello1 from the Select Webapp to redeploy combo box and click OK.
  6. Dismiss the Redeploy Console by clicking Close.

If you have deployed the application using the Ant deploy task you update the application by using the Ant undeploy task (see Undeploying Web Applications) and then using the Ant deploy task.

Divider
Home
TOC
Index
PREV TOP NEXT
Divider

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.