Prerequisites
Skeleton Code
In this Magercise you will access parameters passed into a servlet at the
time of a service request. You will take the passed-in information, format
it, and send it back to the client in the form of an HTML page.
The two parameters are named name and position and are
placed in the requesting URL.
The servlet uses the information in these parameters to complete the screen
display sent back to the browser. Refer to the
course notes for
information on how to access the parameters
and how to generate an HTML
response.
Perform the following tasks:
Add a line of code to the template ServletParameterTest.java
file to set the OutputStream type to HTML.
Get the name and position parameters from the client.
Get a handle to the OutputStream going back to the client so
that it can be used to write the HTML data back to the browser.
Compile the servlet.
Install the servlet in either the JWS or use the servletrunner
to host.
Request the service from a browser by clicking
here
for the JWS or
here
for the servletrunner.
Request the service with the parameters Randy and
Software Mage from a browser by clicking
here
for the JWS or
here
for the servletrunner.
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 extract parameters
passed into a servlet during a service request.
Copyright © 1998 MageLang
Institute.
All Rights Reserved.
|