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 ...

Get J2EE™ and JAX™: Developing Web Applications and Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.