Prerequisites
Skeleton Code
In this Magercise you build a servlet that generates output to be used
in-line, inside a web page. An important difference between this type
of servlet and those that generate complete HTML responses is that the
output MIME type must be "text/plain" and not "text/html".
The servlet is activated via a special servlet tag that is supported by
the Java Web ServerTM. This may not be
available on any other server, be sure to check your server's documentation.
The servlet tag has the form:
<servlet code="ServletName">
</servlet>
Perform the following tasks:
Add a line of code to set the output stream MIME type to
"text/plain".
Add a line of code to get a reference to the output stream being
sent back to the client.
Add a line of code to send the formatted date to the output stream.
Compile the servlet.
Copy the servlet and the file DatePrintServeltDemo.shtml to
location where the Java Web Server can use them.
Request the service from a browser by clicking
here.
The task numbers above are linked to the
step-by-step
help page. Also available
is
a complete solution to the
problem, and a demonstration
of the expected behavior.
When you finish this Magercise you will understand how to write servlets
that provide in-line content generation.
Copyright © 1998 MageLang
Institute.
All Rights Reserved.
|