Using Cookies-Session Tracking
Example 8 : Session Tracking
·
Lets use two servlets - One to store cookie and
other to read cookie
·
Create following files in a folder (Please check
next slide for code)
o HTMLFile
index.html Contains html that
allows user to enter details
o Java
File CreateCookie.java Contains logic to read/write session
content
o DD
ReadCookie.java Contains deployment details.
Deployment Descriptor
o DD
web.xml Contains deployment details. Deployment
Descriptor
·
Compile the Java File as you did in earlier
example
·
Create below structure with files that you
created above
o Folder
"CreateCookie" contains
o I__"WEB-INF"
Folder and index.html
o I__"WEB-INF"
Folder contains "classes" Folder and web.xml File
o I__"classes"
Folder contains "CreateCookie.class" File and ReadCookie.class
·
Deploy the CreateCookie folder inside webapps
folder of Tomcat
·
Bounce the Server
·
Send request using
"http://localhost:8550/CreateCookie/index.html"