• 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

Pushing response back to a client

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably a no-brainer question here for you all but I am writing a very simple chat (yes, another one...) application. Basically I just want it to be all 1-1 based via a servlet on the server.
So a client initiates a conversation with another user and each response gets pushed into each others text area.
I understand the mechanics of it simply enough but am having trouble understanding how to push the response back from the servlet on the server to the applet on the clients PC without them needing to refresh ?
As I said, probably very easy but any help in the right direction would be much appreciated.
Thanks everyone,
Jon
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think the web page with the applet needs to be refreshed in order to see the data transmitted from the server to the applet. As long as the connection is opened between the server and the applet, the applet should display the data sent to it as soon as it is sent.
Disclaimer: I have not done any chat apps and therefore I may be missing something...
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tony Alicea:
I don't think the web page with the applet needs to be refreshed in order to see the data transmitted from the server to the applet. As long as the connection is opened between the server and the applet, the applet should display the data sent to it as soon as it is sent.
Disclaimer: I have not done any chat apps and therefore I may be missing something...


That's only true if he's not using http tunnelling or some other reactionary protocol. You can't "push" HTTP, after all.
An applet running a 2-way protocol would need to repaint its display area or place the returned data in some sort of control that would update its own little corner of the display, same as in any ordinary Java applet - the fact that the data came in from the wire is irrelevant.
 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm curious to know why for HTTP protocol there is no better way than passive polling on some field? By better way, I mean some active notification mechanism that one can use to implement the "push" mechanism ?
Suppose I am writing a mission-critical network monitoring application, where I want to refresh actively because any passive polling may cause some time delay, which I can't afford. How can one do this kind of thing with the HTTP request/response structure ?
Thanks.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sudd,
Well HTTP is a stateless protocol, basically its like this, the client (browser) asks a question, and the server (Web Server/App Server) answer the question back. It does not remember any previous communication nor does it talk back when not being spoken too.
Using HTTP for an application like u described would not be able to work without an auto-refresh built into the HTML because you would need to tell the server to reanswer your question.
Hope that explains some stuff.
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic