0

I have a standalone application in Java which reads data through IPC. Now I want that when the data is read, the Java application pushes the data to the clients on browsers. Can this be achieved? I am a new bee to this, however I think yes it is possible. But don't know how can it be achieved using HTTP.

Nikhil
  • 207
  • 1
  • 3
  • 15
  • Solutions for implementing a server push in Java have already been described here (http://stackoverflow.com/questions/9898066/java-push-from-server-to-clients). Bi-Directional Web Service, JMS... – dasilvj Jan 08 '13 at 13:42

1 Answers1

0

There is deliberately no push in HTTP. This is one of the features that makes it secure and less exploitable by spammers. If you want to simulate a push, the simplest way is to have some JavaScript running on the client that periodically checks for new data.

Chris Broski
  • 2,421
  • 27
  • 23
  • I would not exactly describe the lack of push a feature. If it would fit into the concept of HTTP, I am sure it would have been implemented. Instead, there are a few workarounds, like long polling. Luckily, with HTML5 came server side events and websockets. But basically you are right, the simplest way is still to periodically check via Ajax. – Wutz Jan 08 '13 at 16:29
  • I don't want client to periodically check whether data is available to be read on server. Instead, my requirement is that I want server to push the data to client over HTTP. How WebSockets work? Are they similar to sockets we use in Java? – Nikhil Jan 09 '13 at 04:34