This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Marcus green mock questinos doubt? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Marcus green mock questinos doubt?" Watch "Marcus green mock questinos doubt?" New topic
Author

Marcus green mock questinos doubt?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

following is question no. 65 of test 1 from marcus green mock test


Marks: 1
Which of the following statements are true?
Choose at least one answer.
A. A session will always be invalidated if a user shuts down their browser
B. A session will always be invalidated if the servlet container restarts
C. A session can be invalidated by calling the invalidate method of the HttpSession class
D. A session can be invalidated by calling the delete method of the HttpSession class
E. A session cannot be invalidated via programmer code
F. The session timeout interval can be specified in the deployment descriptor


the correct answer according to the site is C and F.

i think the answer should also include E and B.

but my real question is regarding optino B. if a container restarts will always the sessions by invalidated ? sessions are after all Objects and if server restarts they are invalidated. right ? unless some container stores them on database. please help

regards
gurpreet
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1665
    
  25

Answer E is not true because of answer C (HttpSession.invalidate()) can be used to programmatically invalidate the Session)

Answer B is questionable, because the specs don't say anything about it. There is no explicit requirement that a Session object should survive a container crash however many web-containers offer that functionality. If you would have to answer the question with the specs in mind you would say: yes is it a correct answer.

Regards,
Frits
Sebastien French
Greenhorn

Joined: Jan 04, 2012
Posts: 26

Hi,

I think F should be correct, you can specify timeout in DD like that :



Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1665
    
  25


the correct answer according to the site is C and F.

i think the answer should also include E and B.


Yes: C and F are also correct, we were only discussing whether to include E and B as correct answers

Regards,
Frits
Sebastien French
Greenhorn

Joined: Jan 04, 2012
Posts: 26

I read too quicly the question, sorry :'(
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

thanks alot Fritz for clearing doubts regarding option B

for option E i was reading cannot as can
Ankit Gareta
Ranch Hand

Joined: Mar 28, 2011
Posts: 67

Hi All,

Sessions are stored depends on web-browsers(means stored in cookies depends on web-browser),
So i think when the servlet container restarts doesn't make a signal to invalidate session value that stored , so i think the answer B is wrong.
But i don't read the spec till.

wrong me if i wrong.
Thanks,
Ankit


OCPJP 6 (91%)
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1665
    
  25

Hi Ankit,

The Session object lives on the Server, the reference to a Session object lives in the browser (in a Cookie). If you kill the browser, the reference is lost, but the Session object is still on the server.

If you restart the server, the Session object will be destroyed. The Servlet-container builders, however, can provide a service that will recreate the Session object after a shutdown/restart of the server (e.g. by serializing and de-serializing the Session objects). As the specifications don't require that a Session object should be recreated after a shutdown/restart of the server you can conclude that B is correct

Regards,
Frits
Ankit Gareta
Ranch Hand

Joined: Mar 28, 2011
Posts: 67

Hi Frits,
Frits Walraven wrote:Hi Ankit,

The Session object lives on the Server, the reference to a Session object lives in the browser (in a Cookie). If you kill the browser, the reference is lost, but the Session object is still on the server.

If you restart the server, the Session object will be destroyed. The Servlet-container builders, however, can provide a service that will recreate the Session object after a shutdown/restart of the server (e.g. by serializing and de-serializing the Session objects). As the specifications don't require that a Session object should be recreated after a shutdown/restart of the server you can conclude that B is correct

Regards,
Frits

Thanks for you reply, So session object lives on server, so there is two reference of the session, one is in server and another is in browser's cookies.
so if i cleared all the cookies of the browser, that will not affect on session object that are stored in server, right ? session stored in server can be deleted only by invalidate method of HTTPSession while server is running.

Thanks,
Ankit
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1665
    
  25

so if i cleared all the cookies of the browser, that will not affect on session object that are stored in server, right ?

Correct.
session stored in server can be deleted only by invalidate method of HTTPSession while server is running.

Or by the means of a time-out (when it occurs the server will remove the Session object)
- either by setting the global session time-out value in the web.xml (<session-config><session-timeout>30</session-timeout></session-config>) or
- by setting a time-out value on a specific Session object (setMaxInactiveInterval(int interval).

Regards,
Frits
 
jQuery in Action, 2nd edition
 
subject: Marcus green mock questinos doubt?