Could you please quote the question? I do not posses the Head First Servlets and JSP 1st edition book, so it's hard to answer to your question.
Joined: Feb 06, 2011
Ok, some quotations to complete the question in question....
Which about web attributes are true?
(Choose all that apply.)
A. No attributes are longer lived than session attributes.
B. In all scopes, attributes can be retrieved using a getAttribute() methode.
C. Context attributes survive a session time-out.
D. Only session and context attributes can be retrieved in an enumeration.
E. Data stored in both request and session objects is thread safe.
HF tells me that B and C are the correct answers, and I agree questionless upon C.
My remark is about the statement made at B's, because the argument to the method (String name)
is omitted. Not mentionned, zippo, gone with the wind, computer says no
And I do see what they mean to ask (that is, I hope...), but, looking forward to the exam,
I hope not be examined in a way of "we hope you've got what we really intended to ask..."
Bottom-line: how exact are questions to be interpreted on the exam.
Thanks for your response!
PS Would there be a difference between asking about a getAttribute() method and asking about the getAttribute() method?
Yea, I guess it's a common problem how to describe a method without specifying what parameters are you interested in.
ExamLab for OCPJP used the "-" character to denote this, like this: getAttribute(-).
It means that whatever arguments the method takes, they're not important - only the name and overall purpose is important for the question.
Frankly, when reading your question, I would undoubtedly say B is correct, as I would treat getAttribute() as it would be written with the (-) thing I talked about above. But the fact remains - I think they should explicitly said what they had on their minds...
By the way: the same problem is with denoting the class which the method comes from. Some books might use the ServletRequest.getAttribute(String) construct, which can be misleading and understood by some users as it's a static method from the ServletRequest class, where the real purpose was to show that the getAttribute(String) method comes from the ServletRequest class.
Once again - you can use more adequate form taken i.e. from the JavaDoc - ServletRequest#getAttribute(String) which shouldn't be problematic from now on.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com