Which three code fragments, inserted independently at line 5, return the value of the attribute?

Given:
3. public class MyTagHandler extends TagSupport {
4. public int doStartTag() {
5. // insert code here
6. // return an int
7. }
8. // more code here

18. }

There is a single attribute foo in the session scope.
Which three code fragments, inserted independently at line 5, return the value of the attribute?
(Choose three.)

Given:
3. public class MyTagHandler extends TagSupport {
4. public int doStartTag() {
5. // insert code here
6. // return an int
7. }
8. // more code here

18. }

There is a single attribute foo in the session scope.
Which three code fragments, inserted independently at line 5, return the value of the attribute?
(Choose three.)

A.
Object o = pageContext.getAttribute(“foo”);

B.
Object o = pageContext.findAttribute(“foo”);

C.
Object o = pageContext.getAttribute(“foo”,
PageContext.SESSION_SCOPE);

D.
HttpSession s = pageContext.getSession();
Object o = s.getAttribute(“foo”);

E.
HttpServletRequest r = pageContext.getRequest();
Object o = r.getAttribute(“foo”);

Explanation:



Leave a Reply 0

Your email address will not be published. Required fields are marked *