• Post Reply Bookmark Topic Watch Topic
  • New Topic

Refreshing a JSP without losing form data

 
Christopher Elkins
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my problem:
I want to refresh part of a web page without affecting the rest of the page. How do I do this? I know there has to be a way.

Here is some background:
The user has the option of starting a long running process (a report). The report runs in a separate thread in the background so that the user may continue to use the other functions of the web application. I dynamically include page headers and footers via <jsp:include ... />. There is a section of text in the footer that denotes the progress made on downloading a report (if one is running). Currently that text is updated if the user clicks refresh in their browser or visits another page. I would like to write some code to update it every few seconds. I could use a meta-tag or some javascript, but wouldn�t that refresh both the footer and the jsp it is residing on? This is unacceptable because it resets any form values to their defaults thus killing any user progress on that page.

Thanks for any help you can provide.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to look into AJAX technology for this.
 
Christopher Elkins
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I'll look into it. Do you have any favorite resources on that topic?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I did the tech review for the Manning book Ajax in Action which will be coming out soon, and it has lots of good info. You can get ahold of it (I think) from Manning if you join their 'early bird' program.

Other than that, there's lots of info on the web -- this article is pretty good -- and AJAX is discussed in our very own HTML/Javascript forum (whose co-bartender is one of the Manning book authors).

In a nutshell, you use the XMLHttpRequest javascript object to make "back-door" requests back to the server under javascript control. You can use a JS timer to fire off such a request every few seconds (but beware of overloading the server), and use DOM manipulation to update your footer.
[ October 13, 2005: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!