This set of Advanced Java Multiple Choice Questions & Answers (MCQs) on “JSP Elements”.
1. Which one of the following is correct for directive in JSP? Answer: a 2. Which of the following action variable is used to include a file in JSP? Answer: c 3. Which attribute uniquely identification element? Answer: a 4. “out” is implicit object of which class? Answer: d 5. Which object stores references to the request and response objects? Answer: b 6. What temporarily redirects response to the browser? Answer: c 7. Which tag is used to set a value of a JavaBean? Answer: a 8. Can and <%–comment–%> be used alternatively in JSP? Answer: b 9. Java code is embedded under which tag in JSP? Answer: b 10. Which of the following is not a directive in JSP? Answer: d
a) <%@directive%>
b) <%!directive%>
c) <%directive%>
d) <%=directive%>
Clarification: Directive is declared as <%@directive%>.
a) jsp:setProperty
b) jsp:getProperty
c) jsp:include
d) jsp:plugin
Clarification: jsp:include action variable is used to include a file in JSP.
a) ID
b) Class
c) Name
d) Scope
Clarification: ID attribute is used to uniquely identify action element.
a) javax.servlet.jsp.PrintWriter
b) javax.servlet.jsp.SessionWriter
c) javax.servlet.jsp.SessionPrinter
d) javax.servlet.jsp.JspWriter
Clarification: JspWriter object is referenced by the implicit variable out which is initialized automatically using methods in the PageContext object.
a) sessionContext
b) pageContext
c) HttpSession
d) sessionAttribute
Clarification: pageContext object contains information about directives issued to JSP page.
a)
b) <%@directive%>
c) response.sendRedirect(URL)
d) response.setRedirect(URL)
Clarification: response.sendRedirect(URL) directs response to the browser and creates a new request.
a)
b)
c)
d)
Clarification:
a) True
b) False
Clarification: is an HTML comment. <%–comment–%> is JSP comment.
a) Declaration
b) Scriptlet
c) Expression
d) Comment
Clarification: Scriptlet is used to embed java code in JSP.
a) page directive
b) include directive
c) taglib directive
d) command directive
Clarification: command directive is not a directive in JSP.