GSNA · Question #272
You work as a programmer for uCertify.Inc. You have a session object named session1 with an attribute named Attribute1, and an HttpSessionBindingEvent object binding1 bound to session1. Which of the…
The correct answer is A. Object obj=binding1.getSession().getAttribute("Attribute1"); D. Object obj=session1.getAttribute("Attribute1"). The following two code are used to retrieve Attribute1: 1.Object obj=session1.getAttribute("Attribute1"); The getAttribute() method is used to retrieve the bound object with the specified name in this session, or null if no object is bound under the name. 2.Object…
Question
You work as a programmer for uCertify.Inc. You have a session object named session1 with an attribute named Attribute1, and an HttpSessionBindingEvent object binding1 bound to session1. Which of the following will be used to retrieve Attribute1?
Options
- AObject obj=binding1.getSession().getAttribute("Attribute1");
- BObject obj=binding1.getAttribute("Attribute1");
- CLong MyAttribute=session1.getAttribute("Attribute1");
- DObject obj=session1.getAttribute("Attribute1");
- EString str1=session1.getAttribute("Attribute1");
How the community answered
(36 responses)- A72% (26)
- B11% (4)
- C3% (1)
- E14% (5)
Explanation
The following two code are used to retrieve Attribute1: 1.Object obj=session1.getAttribute("Attribute1"); The getAttribute() method is used to retrieve the bound object with the specified name in this session, or null if no object is bound under the name. 2.Object obj=binding1.getSession().getAttribute("Attribute1"); The getSession() gets the current valid session associated with this request. a String object. Answer: B is incorrect. The HttpSessionBindingEvent object cannot use the getAttribute()
Topics
Community Discussion
No community discussion yet for this question.