Connecting Tech Pros Worldwide Forums | Help | Site Map

How to refresh HTML page from MySQL

Newbie
 
Join Date: Aug 2008
Posts: 1
#1: Aug 28 '08
In a WebApplication (Java - NetBeans) in a JSP page I need to refresh a synoptic design (the state of elements) or the records in a table by reading new data from MySQL (apply a java method).
How can I applay this methods every second? I have a javascript methods hwo is running every second.
I can send you the code in the .jsp file.

Thank you very much!

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Aug 29 '08

re: How to refresh HTML page from MySQL


If you want server-side to run after the page has loaded, use Ajax. Every second might be too soon, so you may need to abort the current request or increase it to ten seconds. For the timing, use setInterval.
Expert
 
Join Date: Nov 2006
Posts: 392
#3: Sep 2 '08

re: How to refresh HTML page from MySQL


acoder is correct you would want to use Ajax to do what you describe.

JavaScript and Java(JSP) are completely different technologies and do very different things in different environments. JavaScript runs on the client side in side the browser. It can not directly call Java/JSP methods since they run on the server. You can use JavaScript to call the JSP or servlet to get a new page, or use AJAX to call the server to get data that you can then use to populate the table.
Reply