topic = (Topic) initialContext.lookup("topic/topicStoreComment");
topic = (Topic) initialContext.lookup(Config.PrefixTopicName+"topicStoreComment");
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException  {    Integer toId;    // to user id    Integer fromId;  // from user id    Integer itemId;  // item id    String  comment; // user comment    Integer rating;  // user rating    sp = new ServletPrinter(response, "StoreComment");    /* Get and check all parameters */    String value = request.getParameter("to");    if ((value == null) || (value.equals("")))    {      printError("<h3>You must provide a 'to user' identifier !<br></h3>");      return ;    }    else      toId = new Integer(value);    value = request.getParameter("from");    if ((value == null) || (value.equals("")))    {      printError("<h3>You must provide a 'from user' identifier !<br></h3>");      return ;    }    else      fromId = 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("rating");    if ((value == null) || (value.equals("")))    {      printError("<h3>You must provide a rating !<br></h3>");      return ;    }    else      rating = new Integer(value);    comment = request.getParameter("comment");    if ((comment == null) || (comment.equals("")))    {      printError("<h3>You must provide a comment !<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/topicStoreComment");      // 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_StoreComment : " +e+"<br>");      return ;    }    try     {      sp.printHTMLheader("RUBiS: Comment posting");      // create a sender      TopicPublisher sender = session.createPublisher(topic); // identified publisher      // create a message      MapMessage message = session.createMapMessage();      // set parameters      message.setInt("fromId", fromId.intValue());      message.setInt("toId", toId.intValue());      message.setInt("itemId", itemId.intValue());      message.setInt("rating", rating.intValue());      message.setString("comment", comment);      // 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 comment (got exception: " +e+")<br>");      return ;    }    sp.printHTML("<center><h2>Your comment has been successfully posted.</h2></center>\n");    sp.printHTMLfooter();  }