File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes page refresh using ajax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "page refresh using ajax" Watch "page refresh using ajax" New topic
Author

page refresh using ajax

Angel Ax
Greenhorn

Joined: Jun 03, 2010
Posts: 5
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

Joined: Jan 10, 2002
Posts: 61298
    
  66

What will trigger the refresh of the table? You don't say.

Do you just want it updated at regular intervals?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Angel Ax
Greenhorn

Joined: Jun 03, 2010
Posts: 5
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

Joined: Jan 10, 2002
Posts: 61298
    
  66

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

Joined: Jun 03, 2010
Posts: 5
can you provide some sample code how to do it
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61298
    
  66

Nope. You write the code and we help you with it.
 
GeeCON Prague 2014
 
subject: page refresh using ajax