The J2EETM Tutorial
Home
TOC
Index
PREV TOP NEXT Search
Feedback

Updating Web Clients

During development, you will often need to make changes to Web clients. To update a servlet you modify the source file, recompile the servlet class, update the component in the WAR, and redeploy the application. Except for the compilation step, you update a JSP page in the same way.

To try this feature, first build, package, and deploy the JSP version of the Hello application:

  1. Go to j2eetutorial/examples/src and build the example by running ant hello2.
  2. Create a J2EE application called Hello2App.
    1. Select FileNewApplication.
    2. In the file chooser, navigate to j2eetutorial/examples/src/web/hello2.
    3. In the File Name field, enter Hello2App.
    4. Click New Application.
    5. Click OK.
  3. Create the WAR and add the greeting Web component and all of the Hello2App application content.
    1. Invoke the Web component wizard by selecting FileNewWeb Component.
    2. In the combo box labeled Create New WAR File in Application select Hello2App. Enter Hello2WAR in the field labeled WAR Display Name.
    3. Click Edit to add the content files.
    4. In the Edit Contents dialog box, navigate to examples/build/web/hello2. Select greeting.jsp, response.jsp, and duke.waving.gif, and click Add. Click OK.
    5. Click Next.
    6. Select the JSP radio button.
    7. Click Next.
    8. Select greeting.jsp from the JSP Filename combo box.
    9. Click Finish.
  4. Add the alias /greeting for the greeting Web component.
  5. Specify the context root hello2.
  6. Deploy Hello2App.
  7. Execute the application by pointing a Web browser at http://<host>:8000/hello2/greeting. Replace <host> with the name of the host running the J2EE server.

Now modify one of the JSP files. For example, you could replace the contents of response.jsp with the following:

<h2>Hi, <%=username%>!</h2>
 

To update the file in the WAR and redeploy the application:

  1. Edit response.jsp.
  2. Execute ant hello2 to copy the modified file to the build directory.
  3. Select Hello2App.
  4. In deploytool, select ToolsUpdate Files.
  5. A dialog box appears reporting the changed file.Verify that response.jsp has been changed and dismiss the dialog box.
  6. Select ToolsDeploy. Make sure the checkbox labeled Save Object Before Deploying is checked.

You can also perform steps 4 through 6 by selecting ToolsUpdate And Redeploy. The deploytool utility replaces the old JSP file in Hello2App.ear with the new one and then redeploys the application.

When you execute the application, the response should be changed (Figure 9-3)

Figure 9-3 New Response

Home
TOC
Index
PREV TOP NEXT Search
Feedback