The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 Developing Applications Using Reverse Ajax
Subject:  JSP Same Page different params Problem
Date:  2007-09-17 06:28:28
From:  stojadinovicp
Response to: JSP Same Page different params Problem


In case anyone reads this and has the same problem here is one solution.

Since I already had some user management I simply extended it in the following way. When a user opens the page there is a call to userEntered method. In here I create an instance of UserSession which has two members, username and ScriptSession. ScriptSession you get from wctx.getScriptSession() (this is from the article above) This UserSession is then added to List<UserSession> sessions.

From then on I send messages with
for (UserSession s : sessions) s.addScript(js);
and thats it. (the addScript method has one line: ss.addScript(new ScriptBuffer(js));)

Now, I also have userLeft method which gets called on page onunload event or on a user ping timeout. (users send a ping every few seconds constantly)
in userLeft method I simply remove the UserSession from sessions List and thats it.

Tested on two rooms, works fine.

 Feed java.net RSS Feeds