Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

Get Dynamic Web Content with HTTPRequest

By Doug Davis
2005-04-11


Are applets healthy?

One obvious solution is to use frames. That would work, but it only solves the visual dependency issue between the various items being displayed. Plus, you can't always break apart your UI into well-portioned areas. Another possibility is to make use of applets and DHTML.

If you use an applet, you can pretty much load any piece of data, at will, from the server and with DHTML, figure out the right chunk of HTML to update. This solution actually provides quite a bit of freedom, and it really does allow a Web page designer an incredible amount of freedom to pass data back and forth between the Web browser and the server. You're no longer limited to the explicit GET and POST operations at the page level. I have one problem with an applet-based solution: it requires -- you guessed it -- an applet. Granted, it's just my personal prejudice, but I don't like the idea of requiring the reader of a Web page to download and install a JVM. Depending on the Web page, it might not be that big of an issue. If the readers are technical folks, then they will probably have one installed anyway. However, if I'm putting together a page that will be viewed by non-technical people who don't know the difference between installing a JVM and installing a virus, I believe that this is a worry they should not have to overcome. The other problem with applets is that the communication is limited to just the server from which the original request originated - a good security feature, but it can be a bit limiting.

So, what's left? A while back I came across a nifty little object that's available to JavaScript programmers (and others) that allows you to do an HTTP GET or POST without any effect on the current Web page itself. This means that at any time, either through a timer or some action taken by the viewer of the page, your JavaScript can send a request to any server or URL and get a response. You can then take the data in this response and do whatever you want with it. Ok, big deal, you think. Well, have a look at what you can now do with this.

Take the scenario I mentioned earlier, in which a Web page is acting as a portal for a management system. In some portlet systems, when a portlet needs to be updated it will refresh the entire page, causing all of the problems I just described. However, you can now do an HTTP GET for just one of those portlets and retrieve the new contents, using DHTML to update those contents without affecting any of the others. On the surface it might not seem like such a huge leap in functionality, but it will by the end of this article. First, though, examine this object.

Tutorial Pages:
» A refreshing approach to page refreshes
» Are applets healthy?
» Along came the HttpRequest object
» In Conclusion
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» All about JAXP, Part 1
» Make Database Queries Without the Database
» Load List Values for Improved Efficiency
» 2 Ways To Implement Session Tracking
» A Simple Way to Read an XML File in Java
» Develop Aspect-Oriented Java Applications with Eclipse and AJDT

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources