Dynamic Web Sites with XML, XSLT and JSP (1/4) - exploring XML | WebReference

Dynamic Web Sites with XML, XSLT and JSP (1/4) - exploring XML

Dynamic Web Sites with XML, XSLT and JSP

The times where Web sites with static documents were successful are long over. Today the update frequency and currentness are an important factor for a site's success. There are a lot of mechanisms for producing dynamic content these days. On the server side we have CGI, PHP and servlets, the browser has JavaScript and Java applets.

All of these techniques have in common that the pages cannot be created without programming knowledge. Whereas Web design was a domain of graphics artists and layout artists, today programming specialists are also necessary for building a complete site. This mix of creativity and technology every so often leads to problems and time consuming workarounds: either the design needs to be integrated in the code, or code appears in HTML documents.

The coordination problems resulting in the tight coupling of these two disciplines should be minimized as much as possible. In the remainder of this article we introduce a method, that eases the burden of providing dynamic data and integrating it in the Web site. The basis is a Web server that supports the execution of Java Server Pages (JSP). Inside the JSPs, the dynamic data gets generated that needs to be integrated into the Web design.

Briefly put JSPs are HTML documents into which Java code can be integrated. When such a JSP is requested for the first time, it is turned into a Java servlet and compiled by the Web server, or more precisely the JSP/servlet engine. This servlet then implicitly contains the HTML code. The execution of the code generates the dynamic data and combines it with the HTML to send back to the Web browser.

This approach alone does not yet reach our goal to separate programming from design. Therefore we do not directly generate HTML but take an extra step of saving dynamic data in XML. In order to create HTML for the browser, we hand over the XML data to an XSLT (Extensible Stylesheet Language Transformation) processor, which, aside from the dynamic XML data, takes a static XSLT stylesheet.

Following the rules defined in the stylesheet the processor converts the XML into HTML. After the conversion the HTML document will be sent to the browser and displayed there. With this approach we separate the programmer, who is responsible for the creation of the JSPs and the acquisition of the dynamic data, and the graphics artist, who maintains the transformation logic in the XSLT style sheet. Only the kind of data needs to be agreed upon.

Let's look at the software.

Produced by Michael Claßen

Created: Aug 15, 2001
Revised: Aug 15, 2001