How to sent the MDB onMessage() method's message to HttpServlet

I am creating a web chat application using JMS and MDB as a Message Listener.

I am sending a TextMessage to a QUEUE from a HttpServlet

I have one Message Driven Bean listening to the Queue.When I send the message MDB automatically recieves the message in onMessage() method and getting printed.. so far good.

BUT now i need to display the message in an jsp page when ever the onMessage() method triggers.

Here is my MDB Class

package com.chat.mdb;

import java.io.IOException;

import javax.jms.JMSException;

import org.apache.commons.httpclient.HttpClient;

import org.apache.commons.httpclient.HttpException;

import org.apache.commons.httpclient.methods.GetMethod;

public class ChatBean implements javax.ejb.MessageDrivenBean,

javax.jms.MessageListener {

private javax.ejb.MessageDrivenContext messageContext = null;

public ChatBean() {

}

public void setMessageDrivenContext(

javax.ejb.MessageDrivenContext messageContext)

throws javax.ejb.EJBException {

this.messageContext = messageContext;

}

public void ejbCreate() {

//no specific action required for message-driven beans

}

public void ejbRemove() {

messageContext = null;

}

public void onMessage(javax.jms.Message message) {

System.out.println("Message Driven Bean - Message : \n" + message);

}}

In the above highlighted code i need to take this message to the servlet

to display the message in jsp.

Any help is appreciated.

Regards,

Altosys Java Team

Message was edited by:

Altosys

[1690 byte] By [Altosysa] at [2007-11-26 15:35:57]
# 1

Servlet and JSPs are Client Pull technologies...You can't push from server.

1. OnMessage...put the message in memory or database ....

2. From JSP poll that location continuously and fetch that message.

Also you can use auto refresh option in HMTL tags

<META HTTP-EQUIV="Refresh"

CONTENT="30; URL=http://asdf.com/pullmydata.jsp/">

Regards,

Bhavani

polimetlaa at 2007-7-8 21:53:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Thanks,<META HTTP-EQUIV="Refresh"CONTENT="30; URL= http://asdf.com/pullmydata.jsp/">This is client side pulling of messageWhether is it possible to push from server..?
Altosysa at 2007-7-8 21:53:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Hi,

MultipartResponse will do server push....

http://www.stanford.edu/group/coursework/docsTech/oreilly/com.oreilly.servlet.MultipartResponse.html

But this technique is not good to use in this case.

http://sourceforge.net/projects/webjabber/

http://sourceforge.net/projects/guj/

http://sourceforge.net/projects/jeti/

Jabber is very good one....Many times we dont try to write chat applications...find some nice open source project and use it to save time....

That depends on your project situation.

http://www.jabber.org/

Thank you,

Bhavani

polimetlaa at 2007-7-8 21:53:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...