Example Servlets
- A Servlet Generating
Plain Text.
- Line 13: Note the similarity between out.println and
System.out.println. The latter writes to standard
output; the former writes to the response object.
- Line 7: If a Servlet does not need to receive parameters from the
client, it can ignore the HttpServletRequest object.
- A Servlet Generating
HTML.
- Line 12: Required if response content is HTML.
- Lines 15-19: Constructs the lines of a web page.
- Line 20: Explicitly closes output stream.
- Lines 23-25: Provides Servlet documentation (overrides method in
GenericServlet class).