By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,292 Members | 1,514 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,292 IT Pros & Developers. It's quick & easy.

how to show server time clock in client

P: 34
Hi,
I am using struts 2.
I need to have a clock ticking every second in my webpage to show server time. I do not want to refresh my whole page every second and i do not want to use applet.

Now how can i display time in my webpage?

I wrote jsp code like the following:::::

Expand|Select|Wrap|Line Numbers
  1. <% 
  2. java.util.Date d= new java.util.Date();
  3. DateFormat df = DateFormat.getDateInstance();
  4. out.println(df.format(d));
  5. %>
  6.  
But it is not refreshing.
I want that it should not refresh my whole page but it should refresh the time only.
Jun 30 '08 #1
Share this Question
Share on Google+
1 Reply


P: 52
Hi, so what you mean is you want outomatically the time respondr from the server every second and shows that to you client(web page), as far as I am concerned there is no responds from the server without requests and this is what you need in other way round, so why dont you create some machanism with two clocks where by the other one is the master from your server and the other one is the temp that shows on your client, you syncronises the two and when your page refreshes all it does is to check if your temp and the server clocks are still the same and the temp have to be updated if not, this might not be that 100% accurate but most people did it like that and it is reliable

Kind regards: Sam Rabophala
Jun 30 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.