• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To write a chattting programme

 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you please tell me how to use session to write a chattting programme(facebook chat)
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4676
325
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Kasun.
Can you elaborate your requirement little more? Basically an HttpSession is associated only for a particular user. Why do you need to share that session object?
 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnak you for replying me.I thought the seession would be the best way to implement a chatting Application. that is why i post it.Without sharing the sesssion object how could i share the information between a two particular users.This is my point of view. so if it is wrong please just correct me because i am new to J2EE.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sessions are not shared between users.
 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so how do i make a chat application without using session. is there any other solutions
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4676
325
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use some algorithm to generate a chat ID for any two users who are about chatting. So any chat message that is sent to that chat ID should be delivered to the other person, who is associated to that chat ID.
 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could You please explain it little bit more like which scope should i use?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, not the session (for reasons already mentioned above ). You are going to need some sort of application scoped implementation that can recognize there is a request from userA and they are chatting to userB. That is the fairly easy part, the harder part is how you "push" a chat response to userB, given HTTP does not support pushing data to clients.

You can address this in various ways. One would be to write the client as an Applet that registers itself with some sort of server component. Or you could take the (very naive) approach of having clients poll the server for messages (this is naive, because its hard to see the different between this sort of behaviour and a DDOS attack!). Or you could look at something like Comet which could give you simulated push behaviour.
 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my solution.i use application scope attrributte for users with particular ID.then if i want to chat with paticular user i can change their attribute values.Is it correct?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure I follow what you are suggesting. If you mean you can store some data in the application scope with a key that identifies each user in your chat system then yes that's roughly what you'll need to do. Though like I said, that is the easy bit.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic