I am developing a chat client using java. I was able to connect to gtalk as well as chat using SMACK API. Now I need to do the same with jsp servlets and ajax.
I could do the authentication and getting the buddy list with jsp and servlets only. But I have to use Ajax for the chat (so that page won’t be refreshed).
for sending and receving msgs I use the api s classes in java. The code is below:
public void sendMessage(String message, String to) throws XMPPException
{
Chat chat = connection.getChatManager().createChat(to, this);
chat.sendMessage(message);
}
public void processMessage(Chat chat, Message message)
{
if(message.getType() == Message.Type.chat)
System.out.println(chat.getParticipant() + " says: " + message.getBody());
}
Now how do I do the same in Ajax? Can I use the API methods along with ajax? Or use these in servlets and get the response from servlets with ajax and populate the msg s on the page?
Have a look at DWR