public void doGet(HttpServletRequest request, HttpServletResponse response)
            
throws ServletException, IOException {

        
//初始化参数
            Context ctx=null;
            QueueSender queueSender
=null;
            QueueSession queueSession
=null;
            QueueConnection queueConn
=null;
            
try {
                
//获得上下文
                ctx = new InitialContext();
                
//获得QueueConnectionFactory对象
                QueueConnectionFactory qcfact=(QueueConnectionFactory)ctx.lookup("ConnectionFactory");
                
//获得Queue对象
                Queue queue=(Queue)ctx.lookup("queue/myQueue");
                
                
try {
                    
//获得QueueConnection对象  由QueueConnectionFactory生成
                    queueConn = qcfact.createQueueConnection();
                    
//获得queueSession对象  由QueueConnection对象生成
                    queueSession=queueConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                    
//获得QueueSender对象 由queueSession对象生成
                    queueSender=queueSession.createSender(queue);
                    
//生产TextMessage 并且把TextMessage对象加入到queueSession中
                    TextMessage textMessage=queueSession.createTextMessage();
                    textMessage.setText(
"this is default message..");
                    
//发送
                    queueSender.send(textMessage);
                    
                } 
catch (JMSException e) {
                    e.printStackTrace();
                }
            } 
catch (NamingException e) {
                e.printStackTrace();
            }
finally{
                
//判断是否为空
                if(queueSender!=null&&queueSession!=null&&queueConn!=null){
                    
try {
                        
//管理所有连接
                        queueSender.close();
                        queueSession.close();
                        queueConn.close();
                    } 
catch (JMSException e) {
                        
// TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    
                }
            }
            
        
    }

    
/**
     * The doPost method of the servlet. <br>
     *
     * This method is called when a form has its tag value method equals to post.
     * 
     * 
@param request the request send by the client to the server
     * 
@param response the response send by the server to the client
     * 
@throws ServletException if an error occurred
     * 
@throws IOException if an error occurred
     
*/
    
public void doPost(HttpServletRequest request, HttpServletResponse response)
            
throws ServletException, IOException {

        
this.doGet(request, response);
    }


柴油发电机
发电机
柴油机
柴油发电机
13636374743(上海)
13291526067(嘉兴)