The Example JSP Pages

This chapter illustrates JSP scripting elements using webclient, a version of the hello1 example introduced in Chapter 3 that accesses a web service. To build the webclient example, follow these steps:

  1. Build and deploy the JAX-RPC web service MyHelloService described in Creating a Simple Web Service and Client with JAX-RPC.
  2. In a terminal window, go to <INSTALL>/j2eetutorial14/examples/jaxrpc/webclient/.
  3. Run asant build. This target will spawn any necessary compilations and will copy files to the <INSTALL>/j2eetutorial14/examples/jaxrpc/webclient/build/ directory.
  4. Start the Application Server.

To package and deploy the example using asant, follow these steps:

  1. Run asant create-war.
  2. Start the Application Server.
  3. Run asant deploy-war.

To learn how to configure the example, use deploytool to package and deploy it:

  1. Start deploytool.
  2. Create a web application called webclient by running the New Web Component wizard. Select FileRight ArrowNewRight ArrowWeb Component.
  3. In the New Web Component wizard:
    1. Select the Create New Stand-Alone WAR Module radio button.
    2. Click Browse and in the file chooser, navigate to <INSTALL>/j2eetutorial14/examples/jaxrpc/webclient/.
    3. In the File Name field, enter webclient.
    4. Click Choose Module File.
    5. In the WAR Display Name field, enter webclient.
    6. In the Context Root field, enter /webclient.
    7. Click Edit Contents.
    8. In the Edit Contents dialog box, navigate to <INSTALL>/j2eetutorial14/examples/jaxrpc/webclient/build/. Select duke.waving.gif, greeting.jsp, response.jsp, and the webclient directory, and click Add.
    9. Click OK.
    10. Click Next.
    11. Select the JSP Page radio button.
    12. Click Next.
    13. Select greeting.jsp from the JSP Filename combo box.
    14. Click Finish.
  4. Add an alias to the greeting web component.
    1. Select the greeting web component.
    2. Select the Aliases tab.
    3. Click Add to add a new mapping.
    4. Type /greeting in the Aliases list.
  5. Select FileRight ArrowSave.
  6. Deploy the WAR.

To run the example, open your browser to http://localhost:8080/webclient/greeting.


Note: The example assumes that the Application Server runs on the default port, 8080. If you have changed the port, you must update the port number in the file <INSTALL>/j2eetutorial14/examples/jaxrpc/webclient/response.jsp before building and running the example.