G'day,
I have the following java code to get all of my data from the DB, and is being passed into a vector in my jsp page. My question is, how do i iterate through the vector in jsp?
Vector roomDetails;
Vector hotel;
...
public Vector getHotelRooms(int hotelID){
int count = 0;
try{
Connection connect = new database().getConnection();
Statement con = connect.createStatement();
String sql = "SELECT * FROM hotelrooms WHERE hotelID = '"+hotelID+"'";
ResultSet res = con.executeQuery(sql);
while(res.next()){
count ++;
}
res.beforeFirst();
roomDetails = new Vector();
hotel = new Vector();
while(res.next()){
roomDetails.add(res.getString("roomType"));
roomDetails.add(res.getDouble("roomRate"));
roomDetails.add(res.getDouble("discountRate"));
roomDetails.add(res.getString("discountValidityStart"));
roomDetails.add(res.getDouble("discountValidityEnd"));
hotel.add(roomDetails);
}
}catch(SQLException exc){
exc.printStackTrace();
}
return hotel;
}