%@ page language="java" import="java.util.*, java.sql.*, scart.DBConnection" %>
<%
// Prevent the browser from cacheing this page
response.setHeader ("expires","-1");
DBConnection dbconn = null;
int count = 1;
try {
dbconn = new DBConnection();
}catch (Exception e) {
System.out.println("Error getting DB Connection");
}
ResultSet rs = dbconn.executeQuery("select * from ITEM where ITEM_TYPE = 'B' and INV_QTY > 0" );
%>
Welcome to our online store
Welcome
to our online store |
|
<%
try {
while (rs.next()) { // Continue the loop until all records are read
String itemID = rs.getString("ITEM_ID");
String title = rs.getString("ITEM_TITLE");
String author = rs.getString("AUTHOR_ARTIST");
String qty = rs.getString("INV_QTY");
String price = rs.getString("UNIT_PRICE");
String imagefile = rs.getString("ITEM_IMAGE_FILE");
String desc = rs.getString("ITEM_DESC");
if( desc == null)
desc = " ";
%>
<%= count++ %>.
|
<%= title.trim() %>
|
|
by <%= author.trim() %>
|
<%= desc.trim() %>
Our Price: $<%=price.trim() %>
|
|
<%
} // End Loop
//Check if there are no Books having Inventory > 0. Count will still be 1.
if(count == 1) {
%>
|
OnlineStore is currently out of inventory.
<%
}
}catch(SQLException sqlex){
System.out.println("Error creating Statement" + sqlex);
}
%>
|