throw new EJBException("Problem while computing current bid: "+e+"<br>");
throw new RemoteException("Problem while computing current bid: "+e+"<br>");
  public String getItemDescription(Integer itemId, int userId)  {    String      html = "";    ItemHome    iHome = null;    Item        item = null;    try     {      iHome = (ItemHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/Item"), ItemHome.class);      item = iHome.findByPrimaryKey(new ItemPK(itemId));    }     catch (Exception e)    {      throw new EJBException("Cannot lookup Item: " +e);    }    try    {      float   buyNow   = 0;      int     nbOfBids = item.getNbOfBids();      int     qty      = item.getQuantity();      String  firstBid;      float   maxBid   = item.getMaxBid();      String itemName = item.getName();      if (maxBid == 0)      {        firstBid = "none";        maxBid = item.getInitialPrice();        buyNow = item.getBuyNow();      }      else      {        if (qty > 1)        {          BidHome   bHome = null;          QueryHome qHome = null;          Query     query = null;          try           { // Connecting to Query Home thru JNDI            qHome = (QueryHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/Query"), QueryHome.class);            query = qHome.create();          }           catch (Exception e)          {            throw new EJBException("Cannot lookup Query: " +e);          }          try          {            // Connecting to Bid Home thru JNDI            bHome = (BidHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/Bid"), BidHome.class);          }           catch (Exception e)          {            throw new EJBException("Cannot lookup Bid: " +e);          }          try          {            /* Get the qty max first bids and parse bids in this order               until qty is reached. The bid that reaches qty is the               current minimum bid. */            Enumeration list = query.getItemQtyMaxBid(qty, itemId).elements();            Bid         bid;            int         numberOfItems = 0;            while (list.hasMoreElements())             {              bid = bHome.findByPrimaryKey((BidPK)list.nextElement());              numberOfItems += bid.getQuantity();              if (numberOfItems >= qty)              {                maxBid = bid.getBid();                break;              }            }          }           catch (Exception e)          {            throw new EJBException("Problem while computing current bid: "+e+"<br>");          }        }        Float foo = new Float(maxBid);        firstBid = foo.toString();      }           if (userId>0)      {        //header = printHTMLheader("RUBiS: Bidding\n");        html = html.concat(printHTMLHighlighted("You are ready to bid on: "+itemName));      }      else      {        //header = printHTMLheader("RUBiS: Viewing "+itemName+"\n");        html = html.concat(printHTMLHighlighted(itemName));      }      html = html.concat("<TABLE>\n"+                  "<TR><TD>Currently<TD><b><BIG>"+maxBid+"</BIG></b>\n");      // Check if the reservePrice has been met (if any)      float   reservePrice = item.getReservePrice();      Integer sellerId = item.getSellerId();      if (reservePrice > 0)      { // Has the reserve price been met ?        if (maxBid >= reservePrice)          html = html.concat("(The reserve price has been met)\n");        else          html = html.concat("(The reserve price has NOT been met)\n");      }      html = html.concat("<TR><TD>Quantity<TD><b><BIG>"+qty+"</BIG></b>\n"+                  "<TR><TD>First bid<TD><b><BIG>"+firstBid+"</BIG></b>\n"+                  "<TR><TD># of bids<TD><b><BIG>"+nbOfBids+"</BIG></b> (<a href=\"/servlet/edu.rice.rubis.beans.servlets.ViewBidHistory?itemId="+itemId+"\">bid history</a>)\n"+                  "<TR><TD>Seller<TD><a href=\"/servlet/edu.rice.rubis.beans.servlets.ViewUserInfo?userId="+sellerId+"\">"+item.getSellerNickname()+"</a> (<a href=\"/servlet/edu.rice.rubis.beans.servlets.PutCommentAuth?to="+sellerId+"&itemId="+itemId+"\">Leave a comment on this user</a>)\n"+                  "<TR><TD>Started<TD>"+item.getStartDate()+"\n"+                  "<TR><TD>Ends<TD>"+item.getEndDate()+"\n"+                  "</TABLE>");      // Can the user buy this item now ?      if (buyNow > 0)        html = html.concat("<p><a href=\"/servlet/edu.rice.rubis.beans.servlets.BuyNowAuth?itemId="+itemId+"\">"+                    "<IMG SRC=\"/EJB_HTML/buy_it_now.jpg\" height=22 width=150></a>"+                    "  <BIG><b>You can buy this item right now for only $"+buyNow+"</b></BIG><br><p>\n");      if (userId<=0)      {        html = html.concat("<a href=\"/servlet/edu.rice.rubis.beans.servlets.PutBidAuth?itemId="+itemId+"\"><IMG SRC=\"/EJB_HTML/bid_now.jpg\" height=22 width=90> on this item</a>\n");      }      html = html.concat(printHTMLHighlighted("Item description"));      html = html.concat(item.getDescription());      html = html.concat("<br><p>\n");      if (userId>0)      {        html = html.concat(printHTMLHighlighted("Bidding"));        float minBid = maxBid+1;        html = html.concat("<form action=\"/servlet/edu.rice.rubis.beans.servlets.StoreBid\" method=POST>\n"+                  "<input type=hidden name=minBid value="+minBid+">\n"+                  "<input type=hidden name=userId value="+userId+">\n"+                  "<input type=hidden name=itemId value="+itemId+">\n"+                  "<input type=hidden name=maxQty value="+qty+">\n"+                  "<center><table>\n"+                  "<tr><td>Your bid (minimum bid is "+minBid+"):</td>\n"+                  "<td><input type=text size=10 name=bid></td></tr>\n"+                  "<tr><td>Your maximum bid:</td>\n"+                  "<td><input type=text size=10 name=maxBid></td></tr>\n");        if (qty > 1)          html = html.concat("<tr><td>Quantity:</td>\n"+                    "<td><input type=text size=5 name=qty></td></tr>\n");        else          html = html.concat("<input type=hidden name=qty value=1>\n");        html = html.concat("</table><p><input type=submit value=\"Bid now!\"></center><p>\n");      }    }    catch (RemoteException re)    {      throw new EJBException("Unable to print Item description (exception: "+re+")<br>\n");    }    return html;  }