Page refresh

S

sconeek

Hi all,

i am working on a java based web application.

now i need to access some information stored in a postgres DB in near
real time. at the moment i am refreshing my page every 5sec to get that
information, which is also putting a huge strain on tomcat and hence
chewing up a lot of my memory.

now my question is,
is there a way to display updated information on the screen without
constantly updating it. i was thinking of using javascript sockets,
which will receive information when there is a change within the db and
only then refresh, instead of refreshing every 5sec.

i am sure somebody must have had the same problem and could suggest a
solution. i was also thinking of ajax, but i am not sure about that.
something on the client side would be handy.

thanks to all.
 
D

David Segall

Hi all,

i am working on a java based web application.

now i need to access some information stored in a postgres DB in near
real time. at the moment i am refreshing my page every 5sec to get that
information, which is also putting a huge strain on tomcat and hence
chewing up a lot of my memory.

now my question is,
is there a way to display updated information on the screen without
constantly updating it. i was thinking of using javascript sockets,
which will receive information when there is a change within the db and
only then refresh, instead of refreshing every 5sec.

i am sure somebody must have had the same problem and could suggest a
solution. i was also thinking of ajax, but i am not sure about that.
something on the client side would be handy.
My proposed solution to a similar problem of mine was to issue an
HttpRequest as soon as the page is loaded. The server would respond
with the revised data if there was a change and the client would issue
a new HttpRequest in readiness for the next change. I have not
implemented this so, if you do, please post your conclusions.
 
A

Arvind

AJAX or not, your ''server" load does not change. The only thing
AJAX/Javascript based solutions gives you is to not-reload the browser
page, but go to the server.

Think of it this way. Let us say, for argument sake, you want get the
'current time' from the server every 10 secs

1) You write a helloworld servlet that prints out the current time and
also issues a meta-refresh after 10secs

2) Or you right a html page - that uses javascript/ajax to go the same
servlet, and prints the time.

No matter 1 or 2 - The server will be called 10 times a minute :) -
Only that in practicality, when you load a web page, there are so many
objects that have to be additionally loaded for a html to render (like
css, imgs, .js files etc - though they may be cached by IE) - that
causes more strain than necessary on the server.
 

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
473,772
Messages
2,569,593
Members
45,109
Latest member
JanieMalco
Top