-1
class SessionStorage extends HttpServlet
{       
   public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    {
        HttpSession session=request.getSession();
        int schoolId=100;
        session.setAttribute("schoolId", schoolId);     
    }

}

I just want to know where the schoolId attribute is stored. Either it is on the web container (ex. tomcat) or in Memory (eg .RAM). And which location i will find this attributes if it on the server?

Viju
  • 21
  • 3

2 Answers2

0

SchooldId is saved in the HttpSession (on tomcat). The HttpSession itself is stored in the server's Memory (RAM). You can only look up the value again when a new request for the same http session arrives on the server.

gus3001
  • 851
  • 9
  • 19
  • JVM is running on Server So In JVM different Memory area (like Stack,heap,method Area) used to StoreData . In Which Area the HttpSession attributes stored. Correct me if i am wrong in above sentence. – Viju Jan 24 '18 at 09:10
  • The session is a java object, so that would be stored in the heap. – gus3001 Jan 24 '18 at 09:20
  • how does server know this attribute is for particular user , did it store session Id with attribute in heap? – Viju Jan 24 '18 at 10:53
  • Really depends on the implementation of the server but I imagine one could store it in a HashMap (which would also be contained in the heap). – gus3001 Jan 24 '18 at 11:26
0

SchoolId will be stored in httpSession object. HttpSession will be created in tomcat or any other app/web server

spandey
  • 1,034
  • 1
  • 15
  • 30