| Lesson 3 | The simplest generated page |
| Objective | How do you Write a Servlet that generates HTML? |
| lines 1, 2 and 3 | import statements to permit short class names |
| line 5 | define the servlet class |
| lines 7, 8 | define the doGet method and its two parameters |
| line 9 | list the exceptions this method might throw |
| line 11 | set the content of the response to text/html |
| line 13 | create an output writer attached to the response |
| line 15 | write HTML to the output writer. It will reach the browser eventually |
| lines 17-20 | continue writing HTML to the output writer |
| line 21 | close the output writer |
<html> <head> <title>Hello, World!</title> </head> <body> <h1> Hello, World!</h1> This output was generated by the module 4 servlet. </body> </html>