topic = (Topic) initialContext.lookup("topic/topicStoreBid");
topic = (Topic) initialContext.lookup(Config.PrefixTopicName+"topicStoreBid");
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException  {    Integer userId; // item id    Integer itemId; // user id    float   minBid; // minimum acceptable bid for this item    float   bid;    // user bid    float   maxBid; // maximum bid the user wants    int     maxQty; // maximum quantity available for this item    int     qty;    // quantity asked by the user    sp = new ServletPrinter(response, "StoreBid");    /* Get and check all parameters */    String value = request.getParameter("userId");    if ((value == null) || (value.equals("")))    {      printError("<h3>You must provide a user identifier !<br></h3>");      return ;    }    else      userId = new Integer(value);    value = request.getParameter("itemId");    if ((value == null) || (value.equals("")))    {      printError("<h3>You must provide an item identifier !<br></h3>");      return ;    }    else      itemId = new Integer(value);    value = request.getParameter("minBid");    if ((value == null) || (value.equals("")))    {      printError("<h3>You must provide a minimum bid !<br></h3>");      return ;    }    else    {      Float foo = new Float(value);      minBid = foo.floatValue();    }    value = request.getParameter("bid");    if ((value == null) || (value.equals("")))    {      printError("<h3>You must provide a bid !<br></h3>");      return ;    }    else    {      Float foo = new Float(value);      bid = foo.floatValue();    }    value = request.getParameter("maxBid");    if ((value == null) || (value.equals("")))    {      printError("<h3>You must provide a maximum bid !<br></h3>");      return ;    }    else    {      Float foo = new Float(value);      maxBid = foo.floatValue();    }    value = request.getParameter("maxQty");    if ((value == null) || (value.equals("")))    {      printError("<h3>You must provide a maximum quantity !<br></h3>");      return ;    }    else    {      Integer foo = new Integer(value);      maxQty = foo.intValue();    }    value = request.getParameter("qty");    if ((value == null) || (value.equals("")))    {      printError("<h3>You must provide a quantity !<br></h3>");      return ;    }    else    {      Integer foo = new Integer(value);      qty = foo.intValue();    }    /* Check for invalid values */    if (qty > maxQty)    {      printError("<h3>You cannot request "+qty+" items because only "+maxQty+" are proposed !<br></h3>");      return ;    }          if (bid < minBid)    {      printError("<h3>Your bid of $"+bid+" is not acceptable because it is below the $"+minBid+" minimum bid !<br></h3>");      return ;    }          if (maxBid < minBid)    {      printError("<h3>Your maximum bid of $"+maxBid+" is not acceptable because it is below the $"+minBid+" minimum bid !<br></h3>");      return ;    }          if (maxBid < bid)    {      printError("<h3>Your maximum bid of $"+maxBid+" is not acceptable because it is below your current bid of $"+bid+" !<br></h3>");      return ;    }          try    {      initialContext = new InitialContext();    }     catch (Exception e)     {      printError("Cannot get initial context for JNDI: " + e+"<br>");      return ;    }    TopicConnectionFactory topicFactory = null;    TopicConnection connection = null;    TopicSession session  = null;    Topic topic = null;    try     {      // lookup the connection factory      topicFactory = (TopicConnectionFactory)initialContext.lookup(Config.TopicConnectionFactoryName);      // create a connection to the JMS provider      connection = topicFactory.createTopicConnection();      // lookup the destination      topic = (Topic) initialContext.lookup("topic/topicStoreBid");      // create a session      session  = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); // no transaction and auto ack    }     catch (Exception e)    {      sp.printHTML("Cannot connect to message bean MDB_StoreBid : " +e+"<br>");      return ;    }    try     {      sp.printHTMLheader("RUBiS: Bidding result");      // create a sender      TopicPublisher sender = session.createPublisher(topic); // identified publisher      // create a message      MapMessage message = session.createMapMessage();      // set parameters      message.setInt("userId", userId.intValue());      message.setInt("itemId", itemId.intValue());      message.setFloat("bid", bid);      message.setFloat("maxBid", maxBid);      message.setInt("quantity", qty);      // send the message      connection.start(); // allows message to be delivered (default is connection stopped)      sender.publish(message);      connection.stop();      // close connection and session      sender.close();      session.close();      connection.close();    }     catch (Exception e)    {      printError("Error while storing the bid (got exception: " +e+")<br>");      return ;    }    sp.printHTML("<center><h2>Your bid has been successfully processed.</h2></center>\n");		    sp.printHTMLfooter();  }