• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

To write a chattting programme

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could you please tell me how to use session to write a chattting programme(facebook chat)
 
Sheriff
Posts: 7135
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sessions are not shared between users.
 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so how do i make a chat application without using session. is there any other solutions
 
Devaka Cooray
Sheriff
Posts: 7135
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could You please explain it little bit more like which scope should i use?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic