Server side time updating jsp

P

Paul Lee

Dear all,

I'm trying to develop a jsp which will display the current user and
time server side (so the time will not come from the local PC clock).

I'm hoping to use two javabeans; first to extract the time serverside
and then
display it in the jsp, and the other bean to do the same with the
current userID.

However, I am unsure as to how to do the auto refresh. I would like
this to
happen every second, and I thought about using the <meta-http
equiv="refresh" ... tag, but this will lead to screen flicker at every
refresh. I am looking at the <jsp:forward page="this_current_page.jsp"
/> call but I can't determine if this has a timer/delay parameter
included. I still think that this will cause some flicker, though.

Can anyone help?

Best wishes

Paul
 
C

Chris Smith

Paul said:
However, I am unsure as to how to do the auto refresh. I would like
this to happen every second, and I thought about using the <meta-http
equiv="refresh" ... tag, but this will lead to screen flicker at every
refresh. I am looking at the <jsp:forward page="this_current_page.jsp"
/> call but I can't determine if this has a timer/delay parameter
included. I still think that this will cause some flicker, though.

The jsp:forward action runs on the server as the page is being
generated. It doesn't solve your problem.

Basically, what you've got is a client-side problem; especially give
your desire to avoid refreshing the page. What you need is a client-
side solution (i.e., not JSP) that works with your server-side stuff.
The most obvious answer in JavaScript.

First of all, if your goal in refreshing every second is to keep the
time updated, then you could save a lot of network round-trips and get a
more consistently correct time by decreasing the frequency with which
you update the time from the server, and instead do counting of seconds
on the client in JavaScript. You'd still want to synchronize with the
server occasionally (maybe once every ten seconds) just to avoid time
drift or detect if the server's clock is changed manually.

As for how to do the server interaction, I can see two techniques. You
could use the IE and Netscape-specific XMLHTTPRequest class to ask for
an XML document on the server, which would be generated from a servlet,
and then use that... or you could use that trick where the server never
finishes writing the page and just keeps writing JavaScript <script>
tags that update the earlier content.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top