closeConnection();
  private void itemList(Integer categoryId, Integer regionId, int page, int nbOfItems)   {    String itemName, endDate;    int itemId, nbOfBids=0;    float maxBid;    ResultSet rs = null;    // get the list of items    try    {      conn = getConnection();      stmt = conn.prepareStatement("SELECT items.name, items.id, items.end_date, items.max_bid, items.nb_of_bids, items.initial_price FROM items,users WHERE items.category=? AND items.seller=users.id AND users.region=? AND end_date>=NOW() LIMIT ?,?");      stmt.setInt(1, categoryId.intValue());      stmt.setInt(2, regionId.intValue());      stmt.setInt(3, page*nbOfItems);      stmt.setInt(4, nbOfItems);      rs = stmt.executeQuery();    }    catch (Exception e)    {      sp.printHTML("Failed to execute Query for items in region: " +e);      closeConnection();      return;    }    try     {      if (!rs.first())      {        if (page == 0)        {          sp.printHTML("<h3>Sorry, but there is no items in this category for this region.</h3><br>");        }        else        {          sp.printHTML("<h3>Sorry, but there is no more items in this category for this region.</h3><br>");          sp.printItemHeader();          sp.printItemFooter("<a href=\"/servlet/edu.rice.rubis.servlets.SearchItemsByRegion?category="+categoryId+                             "&region="+regionId+"&page="+(page-1)+"&nbOfItems="+nbOfItems+"\">Previous page</a>", "");        }        closeConnection();        return;      }        sp.printItemHeader();      do      {        itemName = rs.getString("name");        itemId = rs.getInt("id");        endDate = rs.getString("end_date");        maxBid = rs.getFloat("max_bid");        nbOfBids = rs.getInt("nb_of_bids");        float initialPrice = rs.getFloat("initial_price");        if (maxBid <initialPrice)          maxBid = initialPrice;        sp.printItem(itemName, itemId, maxBid, nbOfBids, endDate);      }      while (rs.next());       if (page == 0)      {        sp.printItemFooter("", "<a href=\"/servlet/edu.rice.rubis.servlets.SearchItemsByRegion?category="+categoryId+                           "&region="+regionId+"&page="+(page+1)+"&nbOfItems="+nbOfItems+"\">Next page</a>");      }      else      {        sp.printItemFooter("<a href=\"/servlet/edu.rice.rubis.servlets.SearchItemsByRegion?category="+categoryId+                           "&region="+regionId+"&page="+(page-1)+"&nbOfItems="+nbOfItems+"\">Previous page</a>",                           "<a href=\"/servlet/edu.rice.rubis.servlets.SearchItemsByRegion?category="+categoryId+                           "&region="+regionId+"&page="+(page+1)+"&nbOfItems="+nbOfItems+"\">Next page</a>");      }    }     catch (Exception e)     {      sp.printHTML("Exception getting item list: " + e +"<br>");      closeConnection();    }  }