Hi,
I far i understand Httpsession concepts in Java.
HttpSession ses = req.getSession(true);
will create a session object, according to the request.
setAttribute("String", object);
will, binds the 'String', and value with the Session object.
getAttribute("String");
will return an object associated with the string, specified.
What i cant able to understand is, i am creating a session object like
HttpSession ses = req.getSession(true);
and setting a name for it by calling setAttribute("String", object);
.
Here, This code is resides inside the server. For every person, when he tries to login the same code in the server ll be executed. setAttribute("String", object);
in this method the string value is constant one. So, each session object created will be binded by the same string which i have provided. When I try to retrieve the string for validate his session or while logout action taken the getAttribute("String");
ll return the same constant string value(Am i right!!?? Actually i dont know, i am just thinking of its logic of execution). Then, how can i able to invalidate.
I saw this type of illustration in all of the tutorial in WEB. Is it the actual way to set that attribute? Or, real application developers will give a variable in the "String" field to set it dynamically
(ie. session.setAttribut(userName, userName); //Setting the String Dynamically.. I dono is it right or not.)
And my final question is
WebContext ctx = WebContextFactory.get();
request = ctx.getHttpServletRequest();
What the above two lines will do? What will be stored in ctx & request?
HttpSession ses = req.getSession(true);
will creates new session means. What value stored in ses. (Dont think, how i am came this long without knowing ctx, request & ses. Its very hard to answer).
Thats All...
Any Suggestions & link would be more appreciative!!!
Thanks in Advance!!!