Technical Support
Discussion Forum
Online Training
Technical Articles
Bug Parade
JDC Resources
DukeDollars
Early Access Toolbar

Java Cup Logo
java.sun.com


Solaris Developer Connection

JDC Home Page

Log Out

Online Training
shadowSearchFAQFeedback

Training Index

Fundamentals of JavaTM Servlets: Magercises
Accessing Servlet Service-Time Parameters

By MageLang Institute

[Help | Solution | API Docs | Expected Output | Course Notes | Magercises | Module Intro]

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:

  1. Add a line of code to the template ServletParameterTest.java file to set the OutputStream type to HTML.

  2. Get the name and position parameters from the client.

  3. 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.

  4. Compile the servlet.

  5. Install the servlet in either the JWS or use the servletrunner to host.

  6. Request the service from a browser by clicking here for the JWS or here for the servletrunner.

  7. 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.





Questions?
8-Jan-99
Copyright © 1996-1998 Sun Microsystems Inc.
All Rights Reserved. Legal Terms. Privacy Policy.
Sun Logo