Exercise 2 : Additional Lab Exercise
Note : This lab is not mandatory, it is there if you would like
to take things further. There is little or no sample code although it is
suggested that you use the code from the initial lab exercise as a starting
point.
Passing data from the servlet to the JSP page
In the lab exercise we see how to call a JSP page from within a servlet.
In an actual application we would pass the results of the servlet operation
to the JSP page for display.
Read in a text file in the servlet and store the text file as a Vector
of String objects. The text file to read should be hard coded into the
servlet. Pass this Vector of Strings to the JSP page for display. The crucial
element in this exercise is how to pass information from the servlet to
the JSP page. I would suggest reading the Javadoc for the HttpRequest class.
Extensions
You could make the file which is read by the servlet dynamic by taking
it as a parameter to the servlet.
© Steve Ferris 2000