// cleanup any previous errors
session.removeValue("error");
// obtain success and failure pages
String successpage = req.getParameter("success");
String failurepage = req.getParameter("failure");
// obtain connection to database
initDB();
// debug action?
if (action.equals("debug")) {
debug(req, res);
return;
}
try {
// process an order, we expect a product_id cookie value
if (action.equals("order")) {
String username = getUsername(session);
String password = getPassword(session);
if (!passwordsMatch(username, password)) {
uidPwdError(username, password, failurepage, req, res);
} else {
String product_id = req.getParameter("product_id");
if (product_id == null || product_id.equals("")) {
raiseError("Product ID cannot be empty", failurepage, req, res);
}
if (product_id.length() > 20) {
raiseError("Product ID cannot be > 20 charactes", failurepage, req,
res);
} else {
// generate new unique order_id
// if no orders prior, start at 15344!
int order_id = 15344;
String sqlStmt = "select max (order_id) from userorders";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sqlStmt);
if (rs.next()) {
order_id = rs.getInt(1) + 1;
}
stmt.close();
// now insert a new record
sqlStmt = "insert into userorders (username, order_timestamp,
product_id, order_id) values ( " + username + " , current timestamp,  " + product_id +
" ," + order_id + ")";
stmt = con.createStatement();
int rsi = stmt.executeUpdate(sqlStmt);
if (rsi != 1) {
raiseError("USERORDERSINSERT rs!=1", failurepage, req, res);
}
stmt.close();
// put product_id into session object
session.putValue("product_id", product_id);
res.callPage(successpage, req);
}
}
return;
}
// list orders for a given username
if (action.equals("listorders")) {
String username = getUsername(session);
String password = getPassword(session);
if (!passwordsMatch(username, password)) {
uidPwdError(username, password, failurepage, req, res);
} else {
150
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