Consume Event Response In a Web Application

I have a simple scenario where I have subscribed to a BOSH server to it’s events. Whenever an event occurs I receive xml response from the BOSH server. My program is working perfect in a simple console application. But now I am required to consume the xml response in a web application, my code is as follows:

** public void login(String userName, String password) throws XMPPException {**

** ResourceBundle bundle = ResourceBundle.getBundle(“com.apps.config”);**

** String serverAddress = bundle.getString(“SERVER_ADDRESS”);**

** String domainName = bundle.getString(“DOMAIN_NAME”);**

** XMPPConnection.DEBUG_ENABLED = true;**

** ConnectionConfiguration config = new ConnectionConfiguration(serverAddress, 5222, domainName);**

** connection = new XMPPConnection(config);**

** connection.connect();**

** SASLAuthentication.supportSASLMechanism(“PLAIN”, 0);**

** connection.login(userName, password);**

** PacketFilter filter = new MessageTypeFilter(Message.Type.normal);**

** PacketListener myPacketListener = new PacketListener() {**

** @Override**

** public void processPacket(Packet packet) {**

** //casting packet to XML**

** Message mes = (Message) packet;**

** System.out.println(packet.toXML());**

** System.out.println("----------------------------------------------------------- ------");**

** }**

** };**

** connection.addPacketListener(myPacketListener, filter);**

** }// end method**

How can I modify the processPacket method to consume the response xml in a web application? Thanks in advance for any help;