(i) Copy
CookieAdder.html
into your Web app's root folder. Then copy
CookieAdder.java,
GetPreferences.java
and
ShowSum.java
into the
classesfolder
(ii) Add the appropriate tags to your deployment descriptor and compile the three servlets.
(iii) Start up Tomcat (stopping it first, if it is already running) and then access
the above Web page via your browser. Experiment with differing input to the
Web page. Notice that you will not be permitted to change your preferences
immediately after entering them. However, since the cookies will 'time out' after
3 minutes, you will be able to experiment with other values if you wait for this
timeout and then re-load the initial page.
(iv) Modify
ShowSum.java
so that the result page shows either the date and
time of the user's last visit to the page or, if it is the user's first visit, a messageto indicate this. [Use new to create a
Date
object (package
java.util) and the
Date
object's
toString
method to place the date value into a cookie.] Re-compile
the servlet.
(v) Stop Tomcat, re-start it and then re-test the above application with the
modified servlet.