Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

page refresh using ajax

 
Angel Ax
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

I am facing a problem refreshing a page ....need to use ajax
my Login page calls a servlet (LoginServlet) which has the Business logic and fetches data from the db and fwd its to a jsp page ....I am using display tag library to display data ... this table needs to be refreshed after a timegap using ajax also note that there is no event that can be used like a button or something ..

I can do it using response.setheader but that flickers the page .....


Kindly help with some ajax solutions...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will trigger the refresh of the table? You don't say.

Do you just want it updated at regular intervals?
 
Angel Ax
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it should get updated without a trigger as my jsp page has only a table and no button or textboxes

Also note that the data is passed in a hashtable from the servlet to the jsp where it get displayed
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use window.setInterval() to cause a timer to go off at regular intervals.

By the way, I strongly suggest adopting jQuery to do your Ajax. There are too may pitfalls to doing Ajax "by hand", and jQuery will allow you to retrive the new table from server and insert it into the DOM with one JavaScript statement.
 
Angel Ax
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you provide some sample code how to do it
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. You write the code and we help you with it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic