5.6. Exercises
5.1 Selectable output format: We now have two output formatter classes: Console and HTML. Adapt either of the example servlets so that it reads an initialization parameter to determine what output format to use. Based on the setting, set the content type to either text/plain or text/html, and then use the appropriate class to format the output.
5.2 Pluggable output format: Extend the code from Exercise 5.1 even further. In that exercise, we are able to add additional format options by changing code in the servlet. We'd like to be able to drop in new formatting classes without having to change our servlet at all. Accept as configuration parameters a MIME type string and a formatter class name. In the servlet, set the content type ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access