Multiple choice technology web technology

Which of the following techniques is likely to return an initialization parameter for a JSP page? (Choose two.)

  1. <%= request.getParameter("myParm") %>

  2. <% String s = getInitParameter("myParm"); %>

  3. <% = application.getInitParameter("myParm") %>

  4. <%= config.getInitParameter("myParm"); %>

  5. <%= getParameter("myParm") %>

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

JSP pages have access to the config implicit object (ServletConfig) and can call getInitParameter() on it (option D). Within a JSP declaration or scriptlet, you can also directly call getInitParameter() (option B) because it's inherited from HttpJspBase/Servlet. Options A and E retrieve request parameters (wrong scope). Option C uses application (ServletContext), which retrieves context-wide init params, not JSP-specific ones.