Java Servlets   «Prev  Next»

Generating Servlet Page - Exercise

Combining static and dynamic HTML

The Objective for this module is to :
Write a servlet and include it in a page with the <SERVLET> tag.

Exercise scoring

This exercise is worth 5 points.
To receive credit, paste your completed code in the text box provided below, and click the Submit button to send your code off into cyberspace.


In this lesson you saw how to use the <SERVLET> tag to combine servlet output with ordinary HTML. Now try it yourself.

Download files

You should download the following files from the Exercise download:, Include.shtml (the HTML presented in this lesson that includes a <SERVLET> tag).


  1. Copy your HelloWorld servlet code to a file called, and remove some of the println() calls so that it emits just a single line of text, such as “Hello from a servlet tag!”
  2. Compile the servlet, and start the Java Web Server.
  3. Copy Include.shtml to the public_html folder for Java Web server.
  4. Copy Include.class to the servlet folder for Java Web Server.
  5. Launch or switch to a browser, and enter this URL to see the combined output of the ordinary HTML and the servlet output:
Paste your code into the text area below once it is all working smoothly.