Pushing data in to a zero-footprint client?

Q

Qu0ll

In traditional client-server programming, the client initiates requests and
the server responds. I have implemented 3 test cases of such an
architecture using NIO, servlets and RMI with zero-footprint clients (i.e.
applets). Now I would like to enhance them by adding the ability for the
server to "push" data into the client i.e. transfer data to the client even
when the client has not requested it.

This doesn't seem possible with the servlet model as the servlet only knows
anything about the client when the doGet() or doPost() methods are invoked.
Am I missing something here? Can it be done with servlets? One possibility
I thought of was to repeatedly and frequently poll doPost() from the client
and only get data back if something is available but this doesn't sound
right.

I have added the enhancement quite easily with NIO. It's simply a matter of
switching from read interest to write interest and reading the data when
it's available. Maybe this is no different from (ie. no better than)
repeatedly polling the servlet?

With RMI, I guess it depends on whether an RMI server can invoke methods on
the RMI client. Can it? Remember I am referring to zero-footprint clients
here (e.g.. applets) where I don't want the user having to run rmiregistry
or rmiserver (unless these can be run programmatically).

--
And loving it,

-Q
_________________________________________________
(e-mail address removed)
(Replace the "SixFour" with numbers to email me)
 
D

derek

applets). Now I would like to enhance them by adding the ability for the
server to "push" data into the client i.e. transfer data to the client even
when the client has not requested it.
This doesn't seem possible with the servlet model as the servlet only knows
anything about the client when the doGet() or doPost() methods are invoked.
Am I missing something here? Can it be done with servlets?

You want to look at Comet.

http://en.wikipedia.org/wiki/Comet_(programming)

I saw an example of it at javaone last year. Really neat stuff. I havent had a
chance to use it in a project myself yet unfortunately.
 
Q

Qu0ll

in message
You want to look at Comet.

http://en.wikipedia.org/wiki/Comet_(programming)

I saw an example of it at javaone last year. Really neat stuff. I havent
had a
chance to use it in a project myself yet unfortunately.


Can that be done with applets? It only mentions HTML-related techniques
like JSP/JSF. I am trying to keep the applet absolutely small so I don't
want to have to load large libraries for comet support.

--
And loving it,

-Q
_________________________________________________
(e-mail address removed)
(Replace the "SixFour" with numbers to email me)
 
M

Matt Humphrey

With RMI, I guess it depends on whether an RMI server can invoke methods
on the RMI client. Can it? Remember I am referring to zero-footprint
clients here (e.g.. applets) where I don't want the user having to run
rmiregistry or rmiserver (unless these can be run programmatically).

RMI can have callback objects so that the server can invoke methods on the
client. It's relatively easy to setup (google for RMI callback) but I find
it messy in that it requires a reverse connection from the server to the
client rather than simply piggybacking on the required client-to-server
connection. No RMI registry is required.

I have swapped out RMI callbacks for a reverse-polling scheme where the
client maintains 2 connections to the server. (My application is intended
only for a small number of users, so this isn't a problem and these
connections are hidden underneath the abstract application API) The 2nd
connection waits on the server for events to arrive. When one does, the
server completes the request and the client receives the event without
polling latency, which is important my application. The client then
re-asserts the "getWaitingEvents" request.

Matt Humphrey http://www.iviz.com/
 
D

derek

Can that be done with applets? It only mentions HTML-related techniques
like JSP/JSF. I am trying to keep the applet absolutely small so I don't
want to have to load large libraries for comet support.
--

Oops i didnt see that part about the applets in your original post.
I see it now.
If you have an applet i would just open a socket to the backend and leave it open.
When the back end needed to send up data, just have it send it up the socket.
Not sure about RMI though since i have never used it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top