在 Apache Geronimo 中部署 Web 服务

清单 3. searchAmazon.jsp

返回文章

Listing 3. searchAmazon.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@page import ="com.amazon.xml.AWSECommerceServer.*" %>
<html>
    <head>
        <title>
            Search Amazon
        </title>
    </head>
    <body>
<% 
try {
    AmazonClient ac = new AmazonClient();
    out.println("Searching Amazon Web Services with ISBN 1590595157 <br>");
    out.println("<br>Results are<br><br>");
    
    Items [] resultItems =  ac.lookupISBN("1590595157");
    if(resultItems!=null && resultItems.length>0)  {
        for (int i = 0; i < resultItems.length; i++) {
            Item[] itemvalues = resultItems[i].getItem();
            if (itemvalues != null) {
                for (int j = 0; j < itemvalues.length; j++) {
                    String [] authors= itemvalues[j].getItemAttributes().getAuthor();
                    StringBuffer authorBuffer=new StringBuffer();
                    If (authorBuffer!=null) {
                        for( int k=0;k<authors.length;k++) {
                            authorBuffer.append(authors[k]);
                            authorBuffer.append(" ");
                        }
                    }
                    out.println("<br>Authors :"+ authorBuffer.toString());
                    out.println("<br>ISBN : "+ itemvalues[j].getItemAttributes().getISBN());
                    out.println("<br>Label : "+ itemvalues[j].getItemAttributes().getLabel());
                    out.println("<br>Price : "+ itemvalues[j].getItemAttributes().getListPrice().getFormattedPrice());
                    out.println("<br>No of pages : "+ itemvalues[j].getItemAttributes().getNumberOfPages());
                    out.println("<br>Publisher : "+ itemvalues[j].getItemAttributes().getPublisher());
                    out.println("<br>Title : "+ itemvalues[j].getItemAttributes().getTitle());
                 }
            }
        }
    }
} catch (Exception e) {}
%>
</body>
</html>

返回文章