The Example JSP Pages
This chapter illustrates JSP scripting elements using
webclient, a version of thehello1example introduced in Chapter 3 that accesses a web service. To build thewebclientexample, follow these steps:
- Build and deploy the JAX-RPC web service
MyHelloServicedescribed in Creating a Simple Web Service and Client with JAX-RPC.- In a terminal window, go to
<INSTALL>/j2eetutorial14/examples/jaxrpc/webclient/.- Run
asantbuild. This target will spawn any necessary compilations and will copy files to the<INSTALL>/j2eetutorial14/examples/jaxrpc/webclient/build/directory.- Start the Application Server.
To package and deploy the example using
asant, follow these steps:To learn how to configure the example, use
deploytoolto package and deploy it:
- Start
deploytool.- Create a web application called
webclientby running the New Web Component wizard. Select FileNew
Web Component.
- In the New Web Component wizard:
- Select the Create New Stand-Alone WAR Module radio button.
- Click Browse and in the file chooser, navigate to
<INSTALL>/j2eetutorial14/examples/jaxrpc/webclient/.- In the File Name field, enter
webclient.- Click Choose Module File.
- In the WAR Display Name field, enter
webclient.- In the Context Root field, enter
/webclient.- Click Edit Contents.
- In the Edit Contents dialog box, navigate to
<INSTALL>/j2eetutorial14/examples/jaxrpc/webclient/build/. Selectduke.waving.gif,greeting.jsp,response.jsp, and thewebclientdirectory, and click Add.- Click OK.
- Click Next.
- Select the JSP Page radio button.
- Click Next.
- Select
greeting.jspfrom the JSP Filename combo box.- Click Finish.
- Add an alias to the
greetingweb component.- Select File
Save.
- 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.jspbefore building and running the example.