nerdexam
Oracle

1Z0-900 · Question #32

Which two statements are true about the relationship between JavaServer Pages (JSP) and servlets? (Choose two.)

B and D are the two correct statements. B is correct because a JSP page is ultimately compiled into a servlet by the JSP container, meaning it has full access to the same implicit objects (request, response, session, application context) and servlet infrastructure that a…

Create Java Web Applications using JSPs

Question

Which two statements are true about the relationship between JavaServer Pages (JSP) and servlets? (Choose two.)

Options

  • AA JSP page must extend the HTTPServlet class to behave like a servlet.
  • BA JSP page has access to the same information, objects, and a context as a servlet.
  • CA JSP page is interpreted by JSPServlet.
  • DA JSP page must be written as either an XML file or a JSP file before it is turned into a servlet.

Explanation

B and D are the two correct statements.

B is correct because a JSP page is ultimately compiled into a servlet by the JSP container, meaning it has full access to the same implicit objects (request, response, session, application context) and servlet infrastructure that a traditional servlet has - just with a different authoring syntax.

D is correct because the JSP specification defines two valid syntactic forms a JSP can take before being compiled: the classic .jsp file format and the XML-based JSP Document format (.jspx). Both are valid source representations that the container then translates into a servlet class.

Why the distractors are wrong:

  • A is wrong - the developer never manually extends HttpServlet; the container auto-generates that servlet code during the translation phase. That's the whole point of JSP.
  • C is wrong - JSPs are compiled into Java servlet bytecode, not merely interpreted. While a JspServlet does handle the initial request/compilation trigger, describing the overall relationship as "interpreted by JSPServlet" is inaccurate.

Memory tip: Think of JSP as "syntactic sugar over servlets" - anything a servlet can do, a JSP can do (B), and the JSP must exist in a recognized source format - either JSP syntax or XML - before that translation can happen (D). The key word is automatic conversion: you never manually extend HttpServlet in a JSP.

Topics

#JSP#Servlets#Compilation#Implicit Objects

Community Discussion

No community discussion yet for this question.

Full 1Z0-900 Practice