Link to home
Create AccountLog in
Avatar of Manish
ManishFlag for India

asked on

Session Tracking

Hellow Experts,
    1. I need stepwise explanation of session tracking  like
 when user request ,it creates session object ......(I dont need code).
  2.Why in System.out.println()  out is not initialized to null?
Plz give answers to these simple questions?
Thanks,
Karan
Avatar of bloodredsun
bloodredsun
Flag of Australia image

1./A session is created for the user by the container unlesss you have configured your server not to. The session infomation is kept on the server but the session id (the number representing the session) is passed as a cookie or wirtten as prt of  the URL

2./It is an integral part of the System object (see here http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html) and cannot be instantiated and therefore initialized.

For 2) just to add that the "out" stream, i.e. the output stream is static and already open, therefore it does not need any initialization to null.
Avatar of Manish

ASKER

So for next request session object extract sessionId from
cookie/url ?
session object  automatically send  sessionId to store in  cookie/url?
Avatar of Manish

ASKER

Why System can not be instantiated?
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
> So for next request session object extract sessionId from cookie/url ?

No, the server extracts the session id from the cokkie/url.

> session object  automatically send  sessionId to store in  cookie/url?

No, the server stores the session id in a cookie/url.
Avatar of Manish

ASKER

Thanks girionis,
   I just to want to clear abt System class,
System class is not static ,so y it is not instantiated?
and is it correct that out is not initialized to null bec
the output stream is static and already open,.
Yes, System is not a static (it is final, for more info on final classes have a look here: http://java.sun.com/docs/books/tutorial/java/javaOO/final.html) but you do not instantiate it because all of its methods are static and therefore you can call them straight aways (without having a referebnce to the System class, since as we said static methods belong to the class and not to each individual instance). Besides the constructor for the System class is private (I think) and even if you wanted you couldn't instantiate it.

> and is it correct that out is not initialized to null bec
>the output stream is static and already open,.

To the best of my knowledge this is correct.
Avatar of Manish

ASKER

Thanks
karan
Correct, you can't instantiate System and the static members such as out and in are already available for use by the JVM
Thank you for accepting, glad I was of help :)