-
Get a monthly update on best practices for delivering successful software.
He who doesn't look ahead remains behind. -- Mexican Proverb
One Ajax technique you see quite a bit of lately is the page preview. This is where the html page is rendered as an image so that you can cast a skeptical eye on a tiny version instead of navigating to a lame page. The tech social bookmarking site dzone features an excellent version of this.
So, how do you get a screenshot of a web page from within a Java app using open source? Back in 2004, Joshua Marinacci wrote a very useful article on just this sort of technology, entitled Java Sketchbook: The HTML Renderer Shootout, Part 1. The article is a bit out of date, but at least one of the tools -- JRex -- is still around and kicking.
All of these tools are intended to be used as components for providing interactive HTML rendering and browsing for desktop applications, but just because it is intended for one thing does not mean you can't use it for another. In fact, you can use this technique of using Swing components to render images with some of the following XHTML/CSS rendering engines.
JRex with Gecko will give you the best and most robust results. For legacy HTML, you many want to use JTidy to clean it up into XHTML before passing it into the last two renderers.
The only thing that worries me is that with Javascript enabled, one could have the same sort of exploits we see in regular browsers, only now targeted at servers that use these embedded rendering engines. Since something like this would run unattended for days and weeks, there's a real concern that things could get out of control. There are ways of sandboxing and locking down, and that's something definitely worth considering.
Related posts:
Topics: Ajax Development
If your title has “How To” in it, your “How To” should provide a code samples.
Comment by Mark, Wednesday, December 20, 2006 @ 2:34 am