This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes JSP, JavaScript, AJAX to update value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JSP, JavaScript, AJAX to update value" Watch "JSP, JavaScript, AJAX to update value" New topic
Author

JSP, JavaScript, AJAX to update value

James Daniel
Ranch Hand

Joined: Sep 24, 2004
Posts: 79
I have a jsp that displays the value of a method in an object that is generated from values in a database. I need to update the page with new values as that object gets updated when the database is updated without refreshing the whole page. Any suggestions?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60761
    
  65

Well, you already mentioned Ajax in your title, so what's your question?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
James Daniel
Ranch Hand

Joined: Sep 24, 2004
Posts: 79
Are there any SPECIFIC suggestions on how to update a jsp with new values as that object gets updated when the database is updated without refreshing the whole page? What is the best approach? Does anyone have any code examples?
[ May 19, 2008: Message edited by: James Daniel ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60761
    
  65

Specific answer usually follow specific questions.

There's no way for the client to know when the database is updated in order to initiate an Ajax call on its own. You're either going to need to rely upon user interaction during which a server check can be made, or poll the server checking for changes.

You could also look into Comet-like extended requests, but that's not generally recommended or particularly scalable.
 
Consider Paul's rocket mass heater.
 
subject: JSP, JavaScript, AJAX to update value
 
Similar Threads
database update error with success message in jsp
REFRESH A JSP PAGE
Updation on checkboxes in JSP
updaing values to database in struts.
Reloading JSP page when there is any update in the database