Summary

In this chapter we covered the server-side processing of XML using Java servlets. The chapter focused the topics around a real-world sample Web site that accepted, stored, and displayed aphorisms. The chapter began by describing the basic components and API of servlets. The life cycle of a servlet is init, service, and destroy. This section also discussed the relationship between the GenericServlet abstract class and the HttpServlet class. The section ended with a walkthrough of the JavaServer Web Development Kit (JSWDK) that is used to run the examples in the chapter.

The next section examined the input side of the sample Web site. Specifically, how to generate and store XML from HTML form data. The ProcessAphorismForm servlet received the input from the AddAphorismForm.html file. The algorithm to process the data was to format a single element of a simple Aphorism markup language and append the element to the end of a single XML document. After storing the XML, the servlet returns a confirmation to the user.

The chapter ened by covering how to transform XML to HTML for display by a Web browser. When more browsers have embedded XSLT engines, you may decide to send the XML directly to the browser. In the meantime (and for large transformations), you can transform the XML on the server side and send HTML to the browser. To implement this transformation, we integrated James Clark's XSLT processor (called XT) into our servlet. The XT processor uses a stylesheet to transform the input document to a result document that is returned to the servlet via a series of SAX events.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.70.132