Helping ordinary people create extraordinary websites!

Get Dynamic Web Content with HTTPRequest

By Doug Davis
2005-04-11

A refreshing approach to page refreshes
The HttpRequest object initially might not seem like a big deal. Explore the possibilities of it when you issue a HTTP GET or POST on a URL for succinct page refreshes that update only a specific portion of the Web page.

This article is for those of you who come across programming features that initially don't seem like such big deals, but in reality, open a vast array of possibilities. I came across such a feature not long ago. Now that I've used it quite a bit, I want to share the little gem with the rest of you. First, a little background: Many times I have put together a Web application and found the traditional way of updating the Web page quite limiting. Typically solutions include:

• Make the user click F5 to refresh the data
• Embed some meta-data that automatically refreshes the page after some timeout
• Use JavaScript and reload the page after some timeout
• Wait for the user to explicitly click a button or link that does a GET or POST

The main gripe I have with all of these solutions is that the level of granularity of the "get new data" is at the page level. By that I mean each one reloads the entire page -- causing flickering and, in some cases, losing my current scroll position. At times as I read a long document and the refresh occurs, the whole page scrolls and takes me back to the top (yes, I'm going to repeat this a lot because it really bugs me). The other complaint I have is that since each works on the page level I lose any updates I might have made on the page. For example, with any of the above auto-refresh options, when I enter data and click a Submit button, I lose any updates I made to text entry fields prior to clicking Submit.

You might wonder why I don't want to refresh the entire page. Suppose I have a Web page that acts like a portal for a management system. Perhaps, one section of the page displays log entries as they are generated and another section displays the current load on the system. And in a third section is an area where I am examining other data (large amounts of data) which requires that I scroll a lot. If the screen refreshes every minute or so -- it flickers and loses any temporary information -- like entry fields and scrolling positions of sub-elements -- each time.



Tutorial pages:

First published by IBM DeveloperWorks


 2 Votes

You might also want to check these out:


Leave a Comment on "Get Dynamic Web Content with HTTPRequest"
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS