No, “HTML Generation” is not another name for the children born in the 1980s, many of whom grew up browsing the web—although Jason and Will, saddled with the Generation X moniker, feel that would be only fair. HTML generation is an alternate way for servlets to send HTML content to clients.
So far, every example in this book has generated its HTML by hand, as
String that is sent to the client. This
strategy works fine for small web pages (like book examples), but it
quickly becomes unwieldy for larger, more complicated pages. For that
type of page, it’s sometimes helpful to use an HTML generation
An HTML generation package provides a servlet with a set of classes that abstract away the details of HTML, in particular, the HTML tags. The level of abstraction depends on the package: some put only the thinnest veneer above the HTML tags, leaving the nitty-gritty details (such as opening and closing each HTML tag) to the programmer. Using packages such as these is similar to writing HTML by hand and is not discussed here. Other packages elegantly abstract away the HTML specification and treat HTML as just another set of Java objects. A web page is seen as an object that can contain other HTML objects (such as lists and tables) that can contain yet more HTML objects (such as list items and table cells). This object-oriented approach can greatly simplify the task of generating HTML and make a servlet easier to write, easier to maintain, and sometimes even ...