This set of Advanced Java Multiple Choice Questions & Answers (MCQs) on “JSP”.
1. Which page directive should be used in JSP to generate a PDF page? Answer: a 2. Which tag should be used to pass information from JSP to included JSP? Answer: a 3. Application is instance of which class? Answer: d 4. _jspService() method of HttpJspPage class should not be overridden. Answer: a 5. Which option is true about session scope? Answer: b 6. Default value of autoFlush attribute is? Answer: a 7. Which one is the correct order of phases in JSP life cycle? Answer: c 8. “request” is instance of which one of the following classes? Answer: c 9. Which is not a directive? Answer: c 10. Which is mandatory in Answer: a
a) contentType
b) generatePdf
c) typePDF
d) contentPDF
Clarification: <%page contentType=”application/pdf”> tag is used in JSP to generate PDF.
a) Using <%jsp:page> tag
b) Using <%jsp:param> tag
c) Using <%jsp:import> tag
d) Using <%jsp:useBean> tag
Clarification: <%jsp:param> tag is used to pass information from JSP to included JSP.
a) javax.servlet.Application
b) javax.servlet.HttpContext
c) javax.servlet.Context
d) javax.servlet.ServletContext
Clarification: Application object is wrapper around the ServletContext object and it is an instance of a javax.servlet.ServletContext object.
a) True
b) False
Clarification: _jspService() method is created by JSP container. Hence, it should not be overridden.
a) Objects are accessible only from the page in which they are created
b) Objects are accessible only from the pages which are in same session
c) Objects are accessible only from the pages which are processing the same request
d) Objects are accessible only from the pages which reside in same application
Clarification: Object data is available till session is alive.
a) true
b) false
Clarification: Default value “true” depicts automatic buffer flushing.
a) Initialization, Cleanup, Compilation, Execution
b) Initialization, Compilation, Cleanup, Execution
c) Compilation, Initialization, Execution, Cleanup
d) Cleanup, Compilation, Initialization, Execution
Clarification: The correct order is Compilation, Initialization, Execution, Cleanup.
a) Request
b) HttpRequest
c) HttpServletRequest
d) ServletRequest
Clarification: request is object of HttpServletRequest.
a) include
b) page
c) export
d) useBean
Clarification: Export is not a directive.
a) id, class
b) id, type
c) type, property
d) type,id
Clarification: The useBean searches existing object and if not found creates an object using class.