Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can something like BOSH be implemented using Java Servlets

BOSH (Bidirectional-streams Over Synchronous HTTP) is a sneaky way of implementing 2-way client-server communication in situations where true server-push is not allowed, most obviously to let a server push data to a browser client without having to use client polling.

It works by the client sending a request to the server, and the server doesn't respond immediately... rather it remembers the request but only responds when it has some data to send. When this happens the client immediately sends another request so there is virtually always a 'stored request' sitting on the server ready to push data to the client.

At least, that's how I think it works!

Update: My question is how you can do this using a Java EE stack i.e standard servlets. Is this possible using say Servlet 2.x (I'm a bit rusty so I don't know if you can decline to send a response or something) or only using extensions through a wrapper like Atmosphere?

like image 771
Mr. Boy Avatar asked Jun 30 '26 16:06

Mr. Boy


1 Answers

Not an equivalent but Servlet 3.0 introduces an Asynchronous API. With or without Servlet 3.0, there is also Atmosphere.

See also

  • Servlet 3.0 Asynchronous API or Atmosphere? Easy decision!
  • Asynchronous HTTP and Comet architectures
  • Jean François Arcand blog (the author of Atmosphere)
like image 197
Pascal Thivent Avatar answered Jul 03 '26 07:07

Pascal Thivent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!