| Author |
Auto Refresh Table in JSP
|
Dimitri Supinfo
Greenhorn
Joined: Jun 14, 2012
Posts: 3
|
|
Hello everyone,
i'm quite new to JSP/Servlet architecture.
I would like some help with the following problem, i'm trying to dynamically refresh the content of the following table without refreshing my whole page.
The table is filled by the following Servlet:
What is the best way to achieve my goal.
Thanks in advance.
|
 |
J. Kevin Robbins
Ranch Hand
Joined: Dec 16, 2010
Posts: 380
|
|
|
Use an AJAX call inside a timer loop. If you want to avoid reloading the entire page, AJAX is your only option.
|
"I have a mind like a steel... uh... thingy."
|
 |
Palak Mathur
Ranch Hand
Joined: Jan 29, 2007
Posts: 303
|
|
|
You may like to use Ajax. But I think Bear would be the best person to answer.
|
Palak Mathur | My Blog | TechJaunt | What is JavaRanch? | List of All FAQs
|
 |
Dimitri Supinfo
Greenhorn
Joined: Jun 14, 2012
Posts: 3
|
|
Thank you for your answers,
I don't know how to use AJAX, i could use so help here, would you please give me examples or tutorials?
I've already googled it and didn't find precise examples of what i need.
|
 |
Santiago Tovar
Greenhorn
Joined: Jun 13, 2012
Posts: 11
|
|
|
It's not easy to find exactly what you need, but there are a lot of examples that you can use to understand how it works and do your own code. we can help you with the errors you get in that process.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56162
|
|
Yes, you'll need to use Ajax.
Fire off an Ajax request that returns the HTML fragment (not a full page) that contains the new table markup. Replace the old table element in the DOM with the new fragment.
Do yourself a favor:
Get an Ajax tutorial and read about how Ajax works and what it is.Then use jQuery to do your Ajax call, where it will take one line of code to accomplish the above, rather than the screen-full of code required to do it in raw JavaScript.
As a hint, after you learn the basics of Ajax and jQuery, the code will look something like this:
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Dimitri Supinfo
Greenhorn
Joined: Jun 14, 2012
Posts: 3
|
|
Thanks Bear,
I read tutorials about Ajax and JQuery as you said ! ;)
I wrote something like that and it matches my needs.
|
 |
Tej Ernesto
Greenhorn
Joined: Jun 17, 2012
Posts: 5
|
|
we have to set the Refresh header of the response..
5 indicates that the page refreshes automatically for 5 seconds
response.setHeader("Refresh","5");
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56162
|
|
Tej Ernesto wrote:we have to set the Refresh header of the response..
That will cause the entire page to refresh which is exactly what the question is not about.
|
 |
 |
|
|
subject: Auto Refresh Table in JSP
|
|
|