Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

automatic refreshing

 
James Hewitt
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a java servlet that displays the output of a database (after some manipulation) as an html page. Part of the output is a time. This time is compared to the current time when the page is refreshed, and a calculation is performed to see if the stored time is before or after the current time.
How can I make the servlet automatically redraw the html page every 5 minutes (for example), so I do not have to press the refresh button on the browser?
Many Thanks,
James
 
Cherry Mathew
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Its not a good practice to let the sevlet do that.
u can write a javascript which request the servlet to refresh the page every 5 minutes. Most sports sites do this.
Cherry
 
James Hewitt
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that the servlet is generating the entire html web page, using out.println. Will there be problems if I embed javascript into this? If not, how do I do this?
Thanks,
James
 
James Hewitt
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually ignore this post. I've sorted it with meta tags.
Thanks,
James
 
Anoop Krishnan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai James,
This is not a answer.Do you think that creatting an HTML page from a servlet by simply using the out.println() is good.What happens if you just want to change a single text in your final out put html page ?
You have to change your servlet & redeploy it
Think about it ...........
 
Rehan Malik
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that most of your work is presentation based. I would recommend making a JSP page out of this. At my old company, a portion of their web application had to refresh a page every 30 seconds (which is a similar effect you are looking for). You could easily create a javabean to handle the database connections and the query to the database and return the data as a vector.

Originally posted by James Hewitt:
I have a java servlet that displays the output of a database (after some manipulation) as an html page. Part of the output is a time. This time is compared to the current time when the page is refreshed, and a calculation is performed to see if the stored time is before or after the current time.
How can I make the servlet automatically redraw the html page every 5 minutes (for example), so I do not have to press the refresh button on the browser?
Many Thanks,
James

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic