import java.util.*;
public class Orders {
private Vector orderIDs=new Vector();
private Hashtable timestamps=new Hashtable();
private Hashtable productIDs=new Hashtable();
public Orders() {
super();
}
public void add(String order_id, String order_timestamp, String product_id) {
orderIDs.addElement(order_id);
timestamps.put(order_id, order_timestamp);
productIDs.put(order_id, product_id);
}
public Enumeration orderIDs() {
return orderIDs.elements();
}
public String productID(String orderID) {
return (String) productIDs.get(orderID);
}
public String timestamp(String orderID) {
return (String) timestamps.get(orderID);
}
}
Figure 81. Java code for the Orders bean
Hence, for each resulting row of the query from the USERORDERS
database table, we will add the appropriate order ID, timestamp, and
product ID to an Orders bean. The code to perform this is as follows:
String sqlStmt= select order_id, order_timestamp, product_id from
userorders where username=' +username+ ' ;
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(sqlStmt);
Orders orders=new Orders();
while (rs.next()) {
orders.add(rs.getString( order_id ),
rs.getString( order_timestamp ), rs.getString( product_id));
}
4. Finally, we must set the Orders bean attribute in the Request object
environment and pass control to a JSP page to indicate a successful
retrieval of the Orders list. We do this with the setAttribute and callPage
methods as follows:
req.setAttribute( orders , orders);
res.callPageA(successpage, req);
The JSP page redirected to the variable successpage will be able to pick
up the bean name of  orders , find the Java bean instance of type
penguins.access.db2.Orders from the Request object environment, and
will have access to the information via the bean's public methods.
106
Linux Web Hosting with WebSphere, DB2, and Domino




  

Home

About Services Network Support FAQ Order Contact
 

Linux Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved