The J2EETM Tutorial
Home
TOC
PREV TOC NEXT Search
Feedback

Updating Web Components

During development, you will often need to make changes to components. The deploytool allows you to easily update the contents of a WAR and redeploy the J2EE application.

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

  1. Go to examples/src and build the example by running ant hello2.
  2. Create a J2EE application called hello2.
    1. Select File->New Application or the New Application button.
    2. Enter hello2.ear in the Application File Name field.
    3. Click OK.
  3. Add the greeting web component and all the of the hello2 application content.
    1. Invoke the web component wizard by selecting File->New Web Component or clicking the New Web Component button.
    2. In the combo box labelled Create New WAR File in Application select the hello2 application. Enter hello2 in the field labeled WAR Display Name.
    3. Click Add to add the content files.
    4. In the Edit Contents dialog, 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. Type greeting in the Web Component Name field.
    10. Click Next and then click Finish.
  4. Add the response web component.
    1. Invoke the web component wizard by selecting File->New Web Component or clicking the New Web Component button.
    2. In the combo box labelled Add to Existing WAR File select the hello2 WAR.
    3. Click Next.
    4. Select the JSP radio button.
    5. Click Next.
    6. Select response.jsp from the JSP File Name combo box.
    7. Type response in the Web Component Name field.
    8. Click Next and then click Finish.
  5. Add the alias /greeting for the greeting web component.
  6. Specify the context root hello2.
  7. Deploy the hello2 application.
  8. 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:

<h2><font color="red">Hello, <%=username%>!</font></h2> 

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

  1. Select the hello2 application.
  2. Click the Update Files button. A message should appear indicating that response.jsp has changed and reminding you to save the application.
  3. Dismiss the message.
  4. Select File->Save or the Save button.
  5. Deploy the hello2 application.

You can also perform steps 2. through 5. by clicking the Update and Redeploy button.

When you execute the application, the color of the greeting should be red:

Home
TOC
PREV TOC NEXT Search
Feedback