Lecture Assignment
Tutorial Week 5
Our readings (lecture notes and video lecture) this week discuss the Servlet (session tracking
and database programming in Servlet). Write the answers for all questions in the table
according to your understanding. PLEASE USE YOUR OWN WORDS. DO NOT COPY FROM
THE WEB.
Questions Answers
1. What is session tracking? What are the three techniques for
session tracking?
2. How do you use hidden values in HTML form for session
tracking? Write example code for session tracking using
hidden values based on the following figure.
3. Write a servlet that stores the following cookies in a browser
and set their max age for two days:
Cookie 1: name is “color” and value is red.
Cookie 2: name is “radius” and value is 5.5.
Cookie 3: name is “count” and value is 2.
MMR2020@FSKM
Lecture Assignment
4. Write a servlet that display all the cookies on the client. The
client types the URL of the servlet from the browser to display
all the cookies stored on the browser.
5. Write a servlet [Link] that retrieve values from a url
html form and send parameter name and studentID using
URL rewriting technique to another servlet. Use
getParameter() method to obtain a parameter value.
6. Create a servlet [Link] and use session
tracking using the Servlet API to keep track the session and
display “Welcome to CSC584 class” to first-time visitors
(within a browsing session) and “Welcome Back” to repeat
visitors. If you did this same task earlier with the Cookie API,
was this servlet harder or easier than the equivalent version
using cookies explicitly?
MMR2020@FSKM