• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Automatic Servlet Refreshing

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Friends,
I want to know as to how a servlet can be automatically refreshed after a given amount of time. The data shown in the servlet should be automatically updated as and when the database is updated.
Advance Thanks.
------------------
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
if you wan tto refresh the servlet after a certian amount of time then use redirect() method with the amount of time to refresh
 
Prabhu Chandrasekaran
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi hanumanth,
can you give me a piece of code to explain?
As for as I know, Redirects are given along with an URL for which the redirect is to be done.
Thanks,

------------------
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Prabhu,
Jason Hunter explains 2 techniques for this kind of auto refresh requirements. 1. Client pull and 2. Server Push.
Client pull - means the client (the browser) automatically makes a request for every *** seconds period.
Server push - means the server sends the reponse automatically to the browser.
I grabbed the code for client pull from Jason Hunter's site for you. This example shows , the client makes a request to every 10 secs to a servlet automatically and diplays the time. See it online here. http://www.servlets.com/servlet/ClientPull
Here is the code. For the other tech (Server push) please go through the examples and find out. I try to post when I come across that. Here is the examples link http://www.servlets.com/jsp/examples/index.html
regds
maha anna
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did anyone try the server push? I tried it on both Websphere and Tomcat, but only the last portion was shown. Is there anything on the server side(servelt engine) that is holding up the flush() which can be changed in the setting?
Thanks.
 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frank/Prabhu,
Here's the link for server push from Jason Hunter's Java Servlet programming book.
http://www.servlets.com/servlet/Countdown
The source is available at this link http://www.servlets.com/jsp/examples/ch06/index.html
Try Example 6-12
Hmenon
 
Frank Lin
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I knew it works on Jason's server. According to him, it is running on Java Web Server 1.1. I just could not run the same example on Tomcat nor on Websphere. Just wonder if anyone has tried it on newer servlet engines.
 
Hema Menon
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frank,
I haven't tried it yet. Hence I am not sure whether it works on any other servers. In Jason's book, he says that server push is not supported by IE(which version?), and is to be avoided if possible since it is found to be harmful for the server's available socket count. I tried the servlet(On Jason's webserver) on IE 5.5 and Netscape 4.73. It worked perfectly on Netscape. But IE did not recognize the type and the result was not expected.
Thanks,
HMenon
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this with J2EE and it works.
One thing that i didn't get though is with ie the response appears one below the another while in netscape the lines seems to refresh showing just the one line at a time..
Any information on this will be appreciated....
[This message has been edited by Ash (edited February 15, 2001).]
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic