how can a servlet automatically updated by its data without refreshing?
This question suggests to me that you don't fully understand the role of a servlet... a servlet generates a one-off response when requested. It doesn't maintain a persistent connection with the client and therefore keep feeding data back*... It is much more like a buffer which builds a response and then sends it all back at once.
A servlet typically gathers the data it needs only when it has to service a response using that data. It shouldn't be 'refreshed' every time that data changes (this is grossly inefficient anyway in the case where you have more refreshes than requests!). If you are maintaining persistent database connections in your servlet, that's fine, but it should only be necessary to check for new data each time the servlet is invoked by a client request.
* Note that this statement is distinct from saying the container may keep an HTTP session with the client; that's a different story. But HTTP is still stateless (no permanent connections unlike FTP or TCP).
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )
Server push will help you. This technology is known for about 8 years, and finally people started using it.
Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss