aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes sessionDestroyed() called before or after valueUnbound() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "sessionDestroyed() called before or after valueUnbound()" Watch "sessionDestroyed() called before or after valueUnbound()" New topic
Author

sessionDestroyed() called before or after valueUnbound()

Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
public class MyListener implements HttpSessionBindingListener, HttpSessionListener
{
public void valueBound(HttpSessionBindingEvent sbe)
{
}
public void valueUnbound(HttpSessionBindingEvent sbe)
{
System.out.println("value unbound");
}
public void sessionCreated(HttpSessionEvent se)
{
}
public void sessionDestroyed(HttpSessionEvent se)
{
System.out.println("session destroyed.");
}
}

When session.invalidate() is called, does it print out "session destroyed. value unbound", or "value unbound session destroyed"?
In another word, after session.invalidate() is called, which is called next, sessionDestroyed() then valueUnbound(), or valueUnbound() then sessionDestroyed() ?


"There are no dumb questions" quoted from HFSJ. "To err is human; to forgive is divine"
OCPJP 6, OCEJWCD 6
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3336
    
    8
Did you try it out?


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
I'd like to try it myself, and then I'd find out the answers myself, but I am currently in a tigh schedule and try to take OCPJWCD 6 exam this month. I am new to WCD so there are plenty to read and to absorb. I did do a google search for it before I posted here, but nothing I found is the exact answer. The best answer I got from search is, after session time out, vauleUnbound() is called before session destroyed. Since currently this forum is not as busy as it is in SCJP forum, I just threw in my questions here for some quick answers as references, and I thank those who answered my questions.

Paul,
Thanks for dropping in. Currently I am doing Enthuware tests. In the first test, I found out a couple of inconsistencies from what I read in 3.0 spec and HFSJ, which I sent to Enthuware from its web site at about 6am yesterday morning to get confirmation. Could you tell me if that is the best way to get in touch with Enthuware support, and usually how long it takes to get an answer back?

In fact, you must have recognized that the question I posted here is one of the test items of yours. I just wanted to make sure it is correct and I tend to think it is correct, because sessionDestroyed() has to be called first so that it'd cause valueUnbound() to be called, but session should not be actually destroyed until after valueUnbound() is called. That is my understanding. Not 100% sure though.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42930
    
  68
I advice against trying to take the exam without doing a fair amount of hands-on web development. Purely theoretical knowledge is not going to get you far in understanding the concepts tested in this exam.
Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
Ulf,
Thanks for the advice, which is very true. Ideally, theory and practice go hand in hand. Theory guides practice, and practice improves the understanding of theory and perfect the theory. I wish I had the luxury of time to do that. Under the constraint of time, I have to temporarily give up practice until after I pass the exam. There are just too many things I need to do. I kind of compare myself with those, who passed the exam, which gives me some confidence in taking the exam. For example, my final mock exam of HFSJ scored 64%. Enthuware mock exam so far -- Test 1: 70%, Test2: 74%, Test3: 81%, Test 4: 77%, which is comparable to the scores of those predecessors. Besides, this is a great web site to get help. The help I got from SCJP forum helped me to pass SCJP 6 three months ago. Hopefully this forum would do the same.
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3336
    
    8
Thanks for dropping in. Currently I am doing Enthuware tests. In the first test, I found out a couple of inconsistencies from what I read in 3.0 spec and HFSJ, which I sent to Enthuware from its web site at about 6am yesterday morning to get confirmation. Could you tell me if that is the best way to get in touch with Enthuware support, and usually how long it takes to get an answer back?

The best way is to just click on the Discuss button on the question view. That will take you to the appropriate topic in the forum and will automatically include the questionid. Or you can email as well. If you contacted using the form on our homepage, did you leave your emailid and the questionid? The questionid is helpful in tracking down the question you are talking about.

HTH,
Paul.
Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
Paul,
Thanks for the response. When I contacted in your web site, I put the question id in title area and my explanation in msg area. I left my email address and checked the check box for a copy to be sent to my email. I did received all two msgs I sent in my email. Could you check to see if you receive those two msgs, each with question id as title. If not, I will do it again. Thanks.
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3336
    
    8
Replied to both of them.

HTH,
Paul.
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3336
    
    8
Regd. your original question, I couldn't find a direct quote on this in the specification but Section A.6.4 says,

A.6.4 Removal of IllegalStateException from HttpSession.getId()
The HttpSessionBindingListener calls the valueUnbound event after the session has been expired, unfortunately, the HttpSession.getId() method is often used in this scenario and is supposed to throw an IllegalStateException. The servlet EG agreed to remove the exception from the API to prevent these types of exceptions.


It says this in Section A.8:

■ Change the behavior of ttpSessionListener.sessionDestroyed to notify before the session is invalidated (15.1.14.1)


Based on the above two, I think sessionDestroyed should be called before valueUnbound.
HTH,
Paul.
Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
Paul,
I really appreciate you spent time to help me with all my questions.

Joe
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3336
    
    8
Joe Allen wrote:Paul,
I really appreciate you spent time to help me with all my questions.

Joe

Sure, not a problem Try the Discuss button next time because it is possible that your doubt may have already been addressed in the thread for that question and you may not need to wait for the answer at all
 
 
subject: sessionDestroyed() called before or after valueUnbound()