CIT 597 Assignment 5: SendText Servlet
Fall 2005, David Matuszek

Purposes of this assignment:

General idea of the assignment:

On my desk at home I have two computers side by side: A Mac and a PC. Often I want to copy text from one to the other. I can do this with a servlet.

On one computer (the client), I open a browser, and go to a specific URL on the other computer (the server). This causes a servlet to execute that opens a GUI on the server, with a text area and two buttons, Cancel and Send. I paste text into the text area, click the Send button, and the server sends a Web page containing my text to the client.

Note that this is an extremely unusual program, since it opens a GUI on the server.


This assignment bears a superficial resemblance to the previous one, but it uses different technology. It's also a program I've written myself, so I know that the programming is easy; getting everything in the right place can be tricky, though.

Here's what you need on the server:

Here's what your servlet needs to do:

The Send button should actually send the text; the Cancel button should also send a valid HTML page, but the text will be "[Cancelled]" or something similar.

You should take care to send correct HTML. Browsers will ignore most of your errors if they can, but that's no excuse for sending incorrect or incomplete HTML.

The received text should be suitable for copying from the Web page and doing something with it. That means it should be plain text. However, the browser is going to try to render it as HTML, which will lose whitespace information and do strange things with characters such as "<" and "&". (Even if the text is HTML, we want to get the non-rendered plain text). To prevent this, the servlet must "cook" the text a little bit before sending it:

(Use the replaceAll method from the String class.)

As a matter of style, the servlet class should do very little work. It should call on another class to get the text to be sent, then send it.

Do not use JSP in this assignment.

Due date:

Wednesday, October 19, before midnight. Zip and turn in all relevant files via Blackboard.