Search your topic in Java2share
Home > SCWCD > SCWCD Question Bank
eXTReMe Tracker

7. Building JSP Pages Using the Expression Language (EL) (SCWCD)


  • Given a scenario, write EL code that accesses the following implicit variables including pageScope, requestScope, sessionScope, and applicationScope, param and paramValues, header and headerValues, cookie, initParam and pageContext.
  • Given a scenario, write EL code that uses the following operators: property access (the . operator), collection access (the [] operator).


Q1. Which EL expression evaluates to the request URI?

A. ${requestURI}
B. ${request.URI}
C. ${request.getURI}
D. ${request.requestURI}
E. ${requestScope.requestURI}
F. ${pageContext.request.requestURI}
G. ${requestScope.request.requestURI}

Answer: F

Q2. Given:

1. <% int[] nums = {42,420,4200};
2. request.setAttribute("foo", nums); %>
3. ${5 + 3 lt 6}
4. ${requestScope['foo'][0] ne 10 div 0}
5. ${10 div 0}

What is the result?
A. true true                                           B. false true
C. false true 0                                       D. true true Infinity
E. false true Infinity                               F. An exception is thrown.
G. Compilation or translation fails.

Answer: E

Q3. You have created a web application that you license to real estate brokers.The webapp is highly customizable including the email address of the broker, which is placed on the footer of each page. This is configured as a context parameter in the deployment descriptor:

10. <context-param>
11. <param-name>footerEmail</param-name>
12. <param-value></param-value>
13. </context-param>

Which EL code snippet will insert this context parameter into the footer?
A. <a href='mailto:${footerEmail}'>Contact me</a>
B. <a href='mailto:${initParam@footerEmail}'>Contact me</a>
C. <a href='mailto:${initParam.footerEmail}'>Contact me</a>
D. <a href='mailto:${contextParam@footerEmail}'>Contact me</a>
E. <a href='mailto:${contextParam.footerEmail}'>Contact me</a>

Answer: C

Q4. Given an EL function foo, in namespace func, that requires a long as a parameter and returns a Map, which two are valid invocations of function foo? (Choose two.)
A. ${func(1)}                                       B. ${foo:func(4)}
C. ${func:foo(2)}                                 D. ${foo(5):func}
E. ${func:foo("easy")}              F. ${func:foo("3").name}