Q)How are protocols classified? 1)stateless protocol 2)stateful protocol =>If server has got no memory of prior connections, the protocol is said to be stateless. If it has, it is stateful. =>FTP(File Transfer Protocol) is a stateful protocol. =>HTTP is a stateless protocol. Note:- HTTP provides better performance but poses some challenges to the web application developers as user interaction with the website should be stateful. Q)What is the purpose of session tracking? =>To make user's interaction with the website stateful,we need to implement session tracking. Q)What is a session? =>In general, time period between user's login and logout is nothing but a session. =>In a Java web application, a session is nothing but HttpSession object. Q)What is session tracking? =>Keeping track of user interaction with the website in a series of client-server interactions is nothing but session tracking. =>Two things are involved in session tracking. 1)user/client identification 2)user's data management. Q)How to implement session tracking in a Java web application? Step 1:- create the session. HttpSession session=request.getSession(); Step 2:- Deal with user's data in session scope Step 3:- End the session Q)What happens in the background when the following statement is executed? HttpSession session=request.getSession(); =>When getSession() method is called on HttpServletRequest object, the following things happen in order. 1) request object is evaluated for in coming session id. Case i:- session id not found in the request object. 2)Container creates a brand new HttpSession object. It also generates a unique session id corresponding to that session object. This session id & session object are maintained by the container as key value pairs. 3)Session Id is written into response object. 4)HttpSession object reference is returned to the servlet. Case ii:- session is id is found in the request object. 2)Container picks up the incoming session id from the request object and searches for the corresponding HttpSession object. 3)Container doesn't create a new HttpSession object. It returns the the reference of already existing HttpSession object. 4)Session id is written into the response object