views:

59

answers:

2

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?

+1  A: 

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

See also

Pascal Thivent
I'm specifically trying to avoid any special technologies right now
John
I'm a bit confused how Atmosphere works... does it 'hack' the JEE server to have special types of servlet?
John
@John No, Atmosphere leverages available APIs (but expose them in a "unified" way). Check the whitepaper on its website.
Pascal Thivent
+1  A: 

Maybe you are looking for something like comet, a kind of reverse AJAX in which the client initiates the connection, allowing the server to push data when it wants.

EDIT: I realize you are looking for solutions in Java and when we think of AJAX we immediately think of JavaScript, but the term has been tainted lately and it represents a concept more than a JavaScript solution. Comet is very much a concept like AJAX and can also be implemented in the programming language of your choice.

Tom
No not really, I'm asking if 'normal' JEE stack i.e servlet 2.x can do this? Since BOSH is widely used I assumed it would be without special server software but I'm rusty on servlets right now.
John
That's all I can help you with, I only know enough Java for a "Hello world" :)
Tom
@John *I'm asking if 'normal' JEE stack i.e servlet 2.x can do this?* Not with extra support (either proprietary support from a container or agnostic if you use Atmosphere).
Pascal Thivent
I see what you mean on Comet, but all the examples on wikipedia talk about client-side aspects, not how you implement the server... i.e make a Servlet not send a response.
John