SIMS 255: Lab 7
November 6, 2003
JSP
In today's lab we will get a simple jsp page running that will accept text from
the user and reverse the word using the code you wrote for Assignment 5. See our
example.
Step 1: Create Message.java
Message.java should:
- implement java.io.Serializable
- be part of a package named your username (e.g. package nadinef;)
- have a class variable of type string called "message"
- have a public constructor with no parameters that initializes "message"
to some default text (NOTE: Pick something interesting to make sure that the
default text will be unique! This will make it easier for us to debug problems.)
- include your reverse word method from the recursion practice part of Assignment
5. (This method should accept a string as a parameter and return the reversed
version of the string - see TAs if you don't have a working version of this.)
- have a setMessage method that takes a string as a parameter and sets the
class variable "message" to it.
- have a getMessage method that returns the class variable "message".
- have a getReversedMessage method that returns the reversed version of the
class variable "message".
Once your class has all of the above and compiles, write a main with hardcoded
values to quickly test that your get and set methods are working correctly and
reversing the string.
When your class methods are working correctly and compile with no errors, create
a folder that is the same name as your package name (username) in your public_html.jsp/WEB-INF/classes/
and place your compiled Message.class file in it.
Step 2: Create the JSP page
Save this file Message.jsp to your public_html.jsp
folder (right-click on the link and choose "Save target as...").
Open it and change the class name to use your class file. The format is class="packageName.className".
In a web browser go to: http://dream.sims.berkeley.edu:8080/[USERNAME]/Message.jsp
and test your page.
Take the time to look over the jsp file and make sure you understand how it
works and what each line does.
NF,JM -- last modified 11/6/03