powered by Jive Software


Can anyone share util examples with smack library??


What kind of examples did you have in mind?


I need examples of JSP pages that send a IM to the webmaster or JSP pages to register on a Jabber server.

Can share a general collection of examples to lear more quickly about Smack?


Yes, I’'d like to see an example that uses JSPs or even

one that is a simple html/servlet combination.

There will be issues with updating the browser when the user receives a message but for the example a simple refresh

meta tag would suffice.


Creating a Jabber client using nothing but JSPs and Servlets is not a real viable solution since those two technologies do not provide a way to “push” content to a client/browser. It might be possible to uses some JavaScript to contact a Jabber server and refresh a JSP/Jabber client at a given interval but that’‘s not going to be a real elegant solution. You’'ll notice that most (all?) Java/web/Jabber clients use applets.

I’'m not trying to dissuade you from your goals but I just want to pass along my experiences and observations when I was looking into doing what it sounds like you re trying to do.

I agree that an HTML based jabber client may not be very compelling. Could someone give a use-case of specifically what you’'d like a JSP example to do? Would the user click on a refresh button or use javascript to poll a page? What functionality would be exposed via this interface and how would a user interact with it?

another way for this - client flash-interface and Flash Remoting or even simple http requests

we are going to do this, using CFMX

at this time server-side part is realized and works (i’'ve tested it with simple html interface)

on server side i’'m using specially written class - envelope for XMPPConnection with additional methods such as login and register:

at first i’‘m trying to login and need to catch exceptions returned from jabber server, especially 401 (Unauthorized). I’‘ve also found that server can return error 401 on the first step of login, that’‘s why a’'m also need to process exception with message “No response from server”

public boolean login(String user, String password, String resource) throws XMPPException, JabberException


boolean res = false;

this.user = user;

this.password = password;

if (this.isConnected()) {

try {

this.connection.login(user, password, resource);

res = true;

} catch (XMPPException xmppe) {

if ((xmppe.getMessage().indexOf(“401”) < 0) && (xmppe.getMessage().indexOf(“response”) <0)) {

throw new XMPPException(xmppe);



} else {

throw new XMPPException(“Not connected!”);


return res;


if login returns false, im trying to register user

public void register()


IQ registerIQ = new IQ ()


public String getQueryXML()


return “<query xmlns=’‘jabber:iq:register’’>” +

“” + user + " " +

“” + password + " " +







In CFMX sending message looks like


js.connect(“cs.rs”, 5222);

js.login(UserName,UserPassword, UserResource);

chat = js.createChat(To, ChatID);

msg = chat.nextMessage(5000);

if (isDefined(“msg”)) {

this.SaveMessage(ChatID, msg.getBody(), 1);

msg = chat.pollMessage();

while (isDefined(“msg”)) {

this.SaveMessage(ChatID, msg.getBody(), 1);

msg = chat.pollMessage();




I have been working on a jsp client, but still get an error when I try to join a room I can use all classes just fine, except for joining a room, I know that the Jabber server has me listed as a participant in the room, but smack comes back with an exception error telling me I have no responce from the server.


if ( session.getAttribute( “sesConnection” ) == null ) {

XMPPConnection connection

= new XMPPConnection(“”);

connection.login(“ColdFusion”, “maxbrite”);

session.setAttribute(“sesConnection”, connection);


XMPPConnection storedConnection = ( XMPPConnection ) session.getAttribute( “sesConnection” );



if (( session.getAttribute( “room” ) == null ) || (request.getParameter(“room”) != null) ){

GroupChat groupConnection = new GroupChat(storedConnection, request.getParameter(“room”)+"@conference.");

session.setAttribute(“room”, groupConnection);



GroupChat storedRoom = ( GroupChat ) session.getAttribute( “room” );


Lately there has been allot of talk of a jsp, coldfusion type client for jabber, there are php and cgi clients…

It might be prudent for someone on the smack team to give connecting to a server and joining a room a try in jsp.

I have looked all over for another easy java package for jabber and your is the only one, I just wish I could join a room…

By the way this the eror from my stack trace:

java.lang.IllegalStateException: Not connected to server.

at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:355)

at org.jivesoftware.smack.GroupChat.join(GroupChat.java:113)

Roman - do you have a website indicating your latest developments with the Flash/HTML/CFMX tool you talked about?



i dont have such site

but when it will working i’'ll tell

as i told only thing that we dont have yet - flash-interface, so i think that it will works in 1-2 weeks

Roman - Great, thanks.

Would be happy with standard HTML+ version, I’'m just eager to see how all the components fit together to make the whole thing work.

Look forward to your announcement.