I have no answer to your question. Only more questions
WHY oh why are you having servlets generate HTML output? I know this is chapter one of servlets books; how we can do CGI in
Java What Sun suggests for an effective presentation of a Web application, is that you delegate presentation to
JSP pages and have Java servlets prep those JSPs with the appropriate beans (objects) that those JSPs will need to render the appropriate UI...
It was called
"Model 2" architecture in the "old" servlet days