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
Posting and Processing HTML Forms

By MageLang Institute

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

Prerequisites

Skeleton Code

This Magercise illustrates how to handle HTML form processing with servlets. In addition, it demonstrates how to dynamically create an HTML display based on data structure information that is processed by the servlet at run time.

The first servlet, FormDisplayServlet, is written for you. It takes two parameters, structurefile and datafile. The first parameter points to a disk file that is a data dictionary file - it describes the structure of the data to be presented. The second parameter points to a disk file that contains the actual data.

FormDisplayServlet takes these two parameters and generates an HTML form on the fly. To the user, it looks like they have a whole table full of editable data. When the user presses the form's

button, the form sends the changed data to FormProcessServlet for processing.

Your task in this Magercise is to complete the development of FormProcessServlet.

Perform the following tasks:

  1. Change the skeleton code for FormProcessingServlet to accept data sent from the client to the server. The client sends an HTTP POST request with a complete set of data from the HTML form.

  2. Write code in FormProcessingServlet to echo the accepted data back to the client in the form of an HTML table. This makes it appear to the user of the browser that they are seeing a non-editable version of the updated information.

  3. Finally, as an advanced part of this Magercise, write the code to store the updated data to the disk. This is not a trivial exercise as you have to think about the problem of multiple people updating data at the same time.

  4. Request the first form to be displayed by sending the URL http://localhost:8080/servlet/FormDisplayServlet?
    structurefile=struct.dat&datafile=data.dat

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 handle HTML FORM processing with servlets.

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