LEARN HOW TO CREATE WEB PAGES IN OO STYLE If you're creating a Web page with a servlet but are having a difficult time embedding the HTML inside Java, use the Apache Jakarta Element Construction Set (ECS). The ECS is a Java application program interface (API) that provides a way to create markup languages. Developers can delegate which objects are responsible for which parts of a marked-up page, thus displaying all the benefits of object-oriented development on a normally non-OO area. It provides support for WML, XML, VXML, and RTF, and is a great tool for simplifying code. Here's an example of a basic servlet code: out.write(""); out.write(title); out.write(""); .... However, with the ECS, you can use objects without having to close your tags, such as: Html html = new Html( ).addElement( new Head( ).addElement( new Title(title) ) ); When you've finished building the Web page, simply output it to the servlet's output stream: html.output(out); ECS can also be useful when outputting XML. Rather than having to deal with all the tags and having to escape certain characters, ECS takes care of it all for you. For example: XML xml = new XML("person") .addXMLAttribute("name", "bayard") .addXMLAttribute("location", "alaska") .addElement( new XML("poster") .addXMLAttribute("name", "tux") ) .addElement( new XML("poster") .addXMLAttribute("name", "gorillaz") ); This code creates the following XML: Visit the Apache Jakarta site to get the latest version of ECS. http://jakarta.apache.org/builds/jakarta-ecs/release/ ----------------------------------------