Multiple choice technology programming languages

Which is the most efficient JspContext method to call to access an attribute that is known to be in application scope?

  1. getPageContext()

  2. findAttribute(String)

  3. getAttribute(String, int)

  4. getAttribute(String)

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The getAttribute(String, int) method is the most efficient way to access an attribute when you know its scope because it bypasses scope searching. The int parameter is a scope constant (APPLICATION_SCOPE, SESSION_SCOPE, REQUEST_SCOPE, PAGE_SCOPE) that directly accesses the specified scope. getAttribute(String) without scope parameter searches all scopes sequentially, while findAttribute() also searches scopes. getPageContext() returns the PageContext object itself, not the attribute value.