I entirely agree with Nathan. The browser does not "listen" for requests
from the server. It can only "listen" for replies to the requests it has
made.
The issue becomes even more complicated when one thinks of a PC running
multiple browser windows or tabs. There could be many different sessions
active - how is the server to know which session to "push" the data to.
In order to "push" data to the browser you will somehow need to create a
listening process on a specific port:- ie. a socket. Once you have a
listening socket you then require program(s) to accept data "pushed" to this
socket (thread processing?) and display it in the browser window.
The only way to do this (that I know of) is to use a Java Applet. Using Java
you set up a socket, receive the data, and display the info in the applet
running in the browser.
Of course the browser needs a URL to get the Java applet in the first place,
but once it is running the server can "push" data to the socket on a regular
basis without the browser making any further requests.
Hope this helps.
Syd
-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On
Behalf Of Nathan Andelin
Sent: 25 September 2008 16:15
To: Web Enabling the AS400 / iSeries
Subject: Re: [WEB400] push data from server to client web browser
From: Thorbjørn Ravn Andersen
The AJAX technologies are all about getting the browser to
process server pushes.
The problem with a statement like that is that somebody will interpret it to
mean that a servlet or cgi program can initiate a conversation with a
browser, and send something to it, similar to the way a batch program can
send an email message to thousands of different smtp servers around the
globe.
I find that even experienced web developers get confused, and sometimes
think they can write a servlet or cgi program that can initiate a
conversation with a browser, and send something to it.
But that's not how servlets and cgi programs work. They can't initiate a
conversation with a client. Browsers always initiate the conversation.
Browsers always make the request. Browsers are always the ones doing the
"pushing".
HTTP servers, web application servers (like Tomcat), servlets, and cgi
programs can only respond (they implement a purely "pull" interface).
Even with AJAX, browsers are in control of the conversation. The browser
makes an asynchronous request. A request may be initiated by a timer event
and run in the background. The request doesn't necessarily require a user
driven event such as a mouse click or keypress. But the browser is always
the one initiating the request-response cycle. The server is only
responding.
Nathan.
As an Amazon Associate we earn from qualifying purchases.