Multiple choice technology programming languages

What statements are correct about the method PageContext.findAttribute(String name)?

  1. 1) There is no such method.

  2. 2) It searches the attribute in all 4 scopes.

  3. 3) It searches the attribute in page scope.

  4. 4) The method is findAttribute(String name, int scope)

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

PageContext.findAttribute(String name) searches for an attribute across all four scopes in order: page, request, session, and application. It returns the first match found or null if not found in any scope. Option B correctly describes this behavior. Option C is wrong because it's not limited to page scope only.

AI explanation

PageContext.findAttribute(String name) searches for an attribute across all four JSP scopes — page, request, session, and application — in that order, returning the first match it finds. This is different from getAttribute(name), which only looks in the page scope unless you use the two-argument overload getAttribute(String name, int scope) to target a specific scope explicitly.