• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Servlet server communication problems

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am writing an internet application that works like an instant messenger. The clients are java apps and the server is a servlet and they are communicating via http. The problem that i am facing is I want when a client sends a message it will be forwarded to the server which will send the message to selected recipients. How do i create a way to identify clients so the server will know who to send the message to? Can this be done? Any help would be appreciated.

Thanks
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

From the java application you can use URLConnection class which allows the HTTP functionality...you can use getInputStream and getOutputStream() to pass data between client and server. This allows for lightweight communication between Servlet/Jsp (Web resource) and a Java application. You can maintain the URL which has fields which identify the clients such as userId=client1 where cilent 1 is generated from Server.

-333
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Do you require users to authenticate themselves? If so, each connection is associated to one particular user. And since each incoming message is also associated to one particular user, the server should be able to figure out whom to forward it to (since it keeps an internal list of ongoing conversations).
 
Elías Porfirio
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf Dittmer and amol deshpande.

I am using URLConnection to connect to the Servlet and the users are not required to authenticate. But if i give the client a session object can this be used to identify them, i know that is what usually happens when users authenticate.

 
The moustache of a titan! The ad of a flea:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic