Automatic update of a part of Jsp
Dear all,
I was wondering if anybody could give me pointers on the direction for this :
I need to update my rows displayed in jsp based on updates done to the database.
Initially I thought I could do this with refreshing the JSP using the Meta tag for every 5 seconds and then having a sql query run for every 5 seconds and compare it with previous results and if the prev.res < new res. then send the data to the jsp. Obviously this is not the right way. I would love to ask for advise on how I should go from here.
That is just a part of the problem. The bigger picture is , I suppose, I will need to use AJAX so that I can update only a *part* of the jsp and not reload the entire page.
I just have no clue how to go from here. Did a lot of google and found something called hotcell for this. Still, I would love to hear back on advises.
Thanks in advance for your time spent on this.
# 1
Use AJAX and have your rows displayed in jsp within a <DIV> tag to dynamically refresh. May be you can use javascript to set the frequency to trigger AJAX call.
If you need AJAX sample code refer the following thread.
http://forum.java.sun.com/thread.jspa?threadID=5193760&messageID=9762322#9762322
skp71a at 2007-7-28 17:47:53 >

# 2
Hi, thanks for your reply. I looked at the ajax code in that post.
attrResponse should be called from my Action class (controller class in my case since am using spring)
However, this is extremely useful if I am expecting the user to do an input for me.
I need to figure out if a Query is updating table abc ( I plan to do it this way :
I will get the table name from all update queries being executed (this I dont know how I will do though), and then after the successfull updation I will execute the select query for the same table) and then return the result set in the attrResponse.
ultimately this will help in updating rows displayed in jsp based on updates done to the database without the page being refreshed. For ex, if my current Jsp is displaying my total no. of employees, which is 2 then if someone updates the table with a third employee, then the third row gets automatically updated.
am I taking it up in the correct way ?
Is there another way to do this ?
Thanks for your time on this.