I'm sorry Michael but I no longer have a working example.  It's not hard to
create though - here's a quick and dirty effort based on the case Harald
described below, you might have to tweak and debug a little to get it
working smoothly, because I have forgotten the exact JS syntax and I haven't
got time to test it.  Hope this helps :)

1. Write a servlet called "DataUpdateCheck" that checks the database thread
for new data, and depending on whether there is new data or not, returns to
the browser EITHER this:

<html>
<head>
<script language="JavaScript">
<!--
delay=3500;     // this could be substituted using a config value from
web.xml
updateUri = "/mywebApp/DataUpdateCheck"; // change this to suit your webapp
x=setTimeout('document.location = "' + updateUri + '";', delay);        
//-->
</script>
</head>
</html>

                OR this:

<html>
<head>
<script language="JavaScript">
<!--
updateUri = "/mywebApp/MainDataPage"; // change this to suit your webapp
document.parent.mainDataFrame.location=updateUri;
//-->
</script>
</head>
</html>

2. Write a servlet called "MainDataPage" which produces the data display for
the user.  You will probably have written this page already.

3. Then write a HTML page that combines the two servlets above:

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<frameset rows="0,*">
<frame name="dataUpdateCheckFrame" src = "DataUpdateCheck">
<frame name="mainDataFrame" src = "MainDataPage">
</frameset>
</HTML>

You could probably use <IFRAME>s instead of <FRAME>s  to make things look
neater in the browser.

> -----Original Message-----
> From: Michael McGrady [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday 19 October 2004 14:57
> To: Tomcat Users List
> Subject: [OT] Re: Push-Server with Tomcat
> 
> 
> Do you have a simple sample of this Steve?  If so, I would 
> sure like to 
> see it.
> 
> Michael McGrady
> 
> Steve Kirk wrote:
> 
> >Not sure if this is stating the obvious, or this is the 
> approach you've
> >already taken, but it's not necesary to refresh the whole 
> page that is
> >displaying your data every few seconds.  You can have an 
> invisible frame
> >that runs the JS timer that you describe.  That frame could have
> >src="/mywebapp/DataUpdateCheck" which is a servlet that 
> returns just a
> >simple js function - if there is new data, the function 
> reloads it into the
> >visible frame, otherwise it reloads itself after a couple of 
> seconds to
> >check for more data.
> >
> >  
> >
> >>-----Original Message-----
> >>From: Steve Kirk [mailto:[EMAIL PROTECTED] 
> >>Sent: Tuesday 19 October 2004 12:41
> >>To: 'Tomcat Users List'; [EMAIL PROTECTED]
> >>Subject: RE: Push-Server with Tomcat
> >>
> >>
> >>
> >>Seems to me that browsers are inherently "pull" technology 
> >>because at the
> >>basic level they send a single request and await a single 
> >>response to it.
> >>You can't push stuff at them that they haven't requested.  
> >>Hence why you
> >>have to use an approach like your javascript - which, by the 
> >>way, I have
> >>used in the past in a web-based control system without 
> >>problems - it might
> >>not feel that elegant, but it does work.
> >>
> >>I would think that to get a true push approach you would have 
> >>to extend the
> >>browser capabilities using a plugin of some sort, e.g. java 
> >>applet / activex
> >>/ etc.  Never tried this myself though so can't comment if 
> >>this will solve
> >>it.
> >>
> >>    
> >>
> >>>-----Original Message-----
> >>>From: Harald Henkel [mailto:[EMAIL PROTECTED] 
> >>>Sent: Tuesday 19 October 2004 09:51
> >>>To: Tomcat Users List
> >>>Subject: Push-Server with Tomcat
> >>>
> >>>
> >>>Hello everybody.
> >>>
> >>>Is it possible (with Tomcat) to write an application that, 
> >>>once startet
> >>>will send a new HTML page to a client, genereated using 
> changed data
> >>>from a database ?
> >>>
> >>>What I want to do is using oracle alerts to alert a waiting Tomcat
> >>>thread of changed data, let it collect the data and generate 
> >>>one or more
> >>>HTML pages sent to different clients, i.e. a specific frame in the
> >>>browser on the client.
> >>>
> >>>Or would I have to have a Java app runing in that frame ?
> >>>
> >>>At the moment I'm doing this using a JavaScript timer on the client
> >>>requesting a new page for that frame every couple of seconds, 
> >>>but for this application push would really be better.
> >>>
> >>>With kind regards,
> >>>Harald Henkel
> >>>
> >>>-- 
> >>>Harald Henkel
> >>>
> >>>GS automation GmbH
> >>>Winterstraße 2
> >>>82223 Eichenau
> >>>Germany
> >>>Tel:    + 49-8141-35 731-37
> >>>Fax:    + 49-8141-35 731-38
> >>>Mobile: + 49-178-7829126
> >>>e-mail: [EMAIL PROTECTED]
> >>>Web:    www.GS-automation.DE
> >>>
> >>>
> >>>      
> >>>
> >>------------------------------------------------------------
> ---------
> >>    
> >>
> >>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>For additional commands, e-mail: 
> [EMAIL PROTECTED]
> >>>
> >>>
> >>>      
> >>>
> >>
> >>------------------------------------------------------------
> ---------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>    
> >>
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> >  
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to