Issue
What are the different ways to track the session in servlet. Is it is possible by using hidden files ?
Solution
There are three ways
One of the ways is to use HttpSession
You can create session using
HttpSession session = request.getSession();
or you can use HttpSession session = request.getSession(true)
. Both statements mean that If there is associated session with this user, then return that one or create a new session. If false
is passed, then new session is not created.
Answered By - Prasad Kharkar
Answer Checked By - David Marino (JavaFixing Volunteer)