Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

Pushing data in to a zero-footprint client?

Thread view: 
Qu0ll - 07 Dec 2007 12:20 GMT
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).

Signature

And loving it,

-Q
_________________________________________________
Qu0llSixFour@gmail.com
(Replace the "SixFour" with numbers to email me)

derek - 07 Dec 2007 13:54 GMT
> 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.
Qu0ll - 07 Dec 2007 14:12 GMT
>> 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
[quoted text clipped - 13 lines]
> 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.

Signature

And loving it,

-Q
_________________________________________________
Qu0llSixFour@gmail.com
(Replace the "SixFour" with numbers to email me)

derek - 07 Dec 2007 14:47 GMT
> 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.
Matt Humphrey - 07 Dec 2007 14:30 GMT
<snip>

> 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/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.