Quick Review:Ajax
Deploy Web services in Apache Geronimo

return new Items[0];

You must register with Amazon to get a subscription ID (see Consuming Amazon Web Services above). After you get your subscription ID, replace it in the code in Listing 2.

Now you're ready to compile this code. After you have run the setenv.bat file, you should be able to compile the code easily by running javac *.java:. You get several class files in this directory. For simplicity of packaging, I copy the entire src directory into a new directory called WEB-INF/classes. Then, from WEB-INF/classes, I delete all the Java source files; from WEB-INF/src, I delete all the class files. If you use an integrated development environment (IDE), such as Eclipse, a lot of this manual work is done for you automatically.

Now you can invoke your Web service and see the results. Use a JSP file to do this.

Write a JSP file to display results from the Web service

Under the amazonclient directory, create a JSP file called searchAmazon.jsp. The code is shown in Listing 3.

In the JSP file shown in Listing 3, you're calling the AmazonClient class that you defined and receiving an array of Item objects. You then iterate over this array to display the values. You now have all the code you need.

Final steps before deploying the code

The last step is to set up the deployment descriptors so you can deploy the WAR file on Geronimo. Under the WEB-INF directory, create two simple XML deployment descriptors. The first is the standard J2EE WAR deployment descriptor, called web.xml (see Listing 4).

Listing 4. web.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app xmlns=""
<display-name>Amazon Sample</display-name>
Geronimo requires a geronimo-jetty.xml descriptor. The code is shown in Listing 5.

May 2008 | Java Jazz Up | 25
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

, 31, 32, 33, 34, 35, 36, 37 Download PDF