0% found this document useful (0 votes)
119 views11 pages

IP Unit 5 MCQ

The document contains a multiple choice quiz with 51 questions about JSP concepts like directives, implicit objects, life cycle phases, and tags. Some key points covered are: - The page directive is used to generate PDF pages - The jsp:param tag passes information between included JSP files - Session scope objects are accessible from pages in the same session - The _jspService() method should not be overridden - JSP pages are compiled into servlets by the container - There are 9 implicit objects available in JSP

Uploaded by

Arijit Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views11 pages

IP Unit 5 MCQ

The document contains a multiple choice quiz with 51 questions about JSP concepts like directives, implicit objects, life cycle phases, and tags. Some key points covered are: - The page directive is used to generate PDF pages - The jsp:param tag passes information between included JSP files - Session scope objects are accessible from pages in the same session - The _jspService() method should not be overridden - JSP pages are compiled into servlets by the container - There are 9 implicit objects available in JSP

Uploaded by

Arijit Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Unit 5 MCQ

1. Which page directive should be used in JSP to generate a PDF page?


a) contentType
b) generatePdf
c) typePDF
d) contentPDF

Answer: a

2. Which tag should be used to pass information from JSP to included JSP?
a) Using <%jsp:page> tag
b) Using <%jsp:param> tag
c) Using <%jsp:import> tag
d) Using <%jsp:useBean> tag

Answer: a

3. Application is instance of which class?


a) javax.servlet.Application
b) javax.servlet.HttpContext
c) javax.servlet.Context
d) javax.servlet.ServletContext

Answer: d

4. _jspService() method of HttpJspPage class should not be overridden.


a) True
b) False

Answer: a

5. Which option is true about session scope?


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

Answer: b

6. Default value of autoFlush attribute is?


a) true
b) false

Answer: a
7. Which one is the correct order of phases in JSP life cycle?
a) Initialization, Cleanup, Compilation, Execution
b) Initialization, Compilation, Cleanup, Execution
c) Compilation, Initialization, Execution, Cleanup
d) Cleanup, Compilation, Initialization, Execution

Answer: c

8. “request” is instance of which one of the following classes?


a) Request
b) HttpRequest
c) HttpServletRequest
d) ServletRequest

Answer: c

9. Which is not a directive?


a) include
b) page
c) export
d) useBean

Answer: c

10. Which is mandatory in <jsp:useBean /> tag?


a) id, class
b) id, type
c) type, property
d) type,id

Answer: a

11. Which one of the following is correct for directive in JSP?


a) <%@directive%>
b) <%!directive%>
c) <%directive%>
d) <%=directive%>

Answer: a

12. Which of the following action variable is used to include a file in JSP?
a) jsp:setProperty
b) jsp:getProperty
c) jsp:include
d) jsp:plugin
Answer: c

13. Which attribute uniquely identification element?


a) ID
b) Class
c) Name
d) Scope

Answer: a

14.“out” is implicit object of which class?


a) javax.servlet.jsp.PrintWriter
b) javax.servlet.jsp.SessionWriter
c) javax.servlet.jsp.SessionPrinter
d) javax.servlet.jsp.JspWriter

Answer: d

15. Which object stores references to the request and response objects?
a) sessionContext
b) pageContext
c) HttpSession
d) sessionAttribute

Answer: b

16. What temporarily redirects response to the browser?


a) <jsp:forward>
b) <%@directive%>
c) response.sendRedirect(URL)
d) response.setRedirect(URL)

Answer: c

17. Which tag is used to set a value of a JavaBean?


a) <c:set>
b) <c:param>
c) <c:choose>
d) <c:forward>

Answer: a

18. Can <!–comment–> and <%–comment–%> be used alternatively in JSP?


a) True
b) False
Answer: b

19. Java code is embedded under which tag in JSP?


a) Declaration
b) Scriptlet
c) Expression
d) Comment

Answer: b

20. Which of the following is not a directive in JSP?


a) page directive
b) include directive
c) taglib directive
d) command directive

Answer: d

21._jspService() method of HttpJspPage class should not be overridden.


A - True
B - False
22. If a jsp is to generate a pdf page, what attribute of page directive it
should use?
A - contentType
B - generatePdf
C - typePDF
B - contentPDF
23. Which of the following attributes are mandatory in <jsp:useBean />
tag?
A - id, type
B - id, class
C - type, class
D - type,property
24. Which of the following is true about session scope?
A - Object created with request scope are accessible only from the page
in which they are created.
B - Object created with request scope are accessible only from the
pages which are in same session.
C - Object created with request scope are accessible only from the
pages which are processing the same request.
D - Object created with request scope are accessible only from the
pages which reside in same application.
25. Which of the following method can be used to read binary data
stream coming from the client?
A - request.getInputStream()
B - response.getInputStream()
C - request.getInputStreamData()
D - response.getInputStreamData()
26.  Which of the following is true about isELIgnored Attribute?
A - The isELIgnored option gives you the ability to disable the
evaluation of scriplets.
B - The isELIgnored option gives you the ability to disable the
evaluation of java code in jsp.
C - The isELIgnored option gives you the ability to disable the evaluation
of Expression Language (EL) expressions.
D - None of the above.

27. What will happen if isELIgnored attribute is set as false?

A - Expression Language (EL) expressions will not be evaluated and will
be treated as static text.

B - JSP container will ignore the EL expressions similar to comments.

C - Both of the above.

D - None of the above.

Answer : A

28 - Which of the following step is taken by JSP container during


Compilation phase?
A - Parsing the JSP.

B - Turning the JSP into a servlet.

C - Compiling the servlet.

D - All of the above.

29 - Is JSP technology extensible?

A - true

B - false

Answer : A

30 - What is the use of <c:set > tag?

A - It can save values to database.

B - It evaluates an expression and uses the results to set a value of a


JavaBean.

C - It can be used to iterate list of elements.

D - None of the above.


31. Whichattribute specifies a JSP page that should process any
exceptions thrown but not caught in the current page?

a. The ErrorPage Attribute


b. The IsErrorPage Attribute
c. Both A & B
d. None of the above

32. Which Error Handling in Java handles runtime errors with exceptions,
If an exception is not caught in your JSP or Servlet, Resin will use a
special error page to send results back to the browser, Resin uses a
default error page unless you explicitly provide an error page yourself?

a. Client Request Time Processing Errors


b. Compilation Time Processing Errors
c. JSP Translation Time Processing Errors
d. None of the above

33. The
ASP and JSP technologies are quite similar in the way they
support the creation of Dynamic pages, using HTML templates, scripting
code and components for business logic.

a. True
b. False

34. Which can generate HTML dynamically on the client but can hardly
interact with the web server to perform complex tasks like database
access and image processing etc. in JSP?
- Published on 22 Jul 15

a. vs.Static HTML
b. vs.Server-Side Includes
c. vs.Pure Servlets
d. Vs.JavaScript

35.
In JSP Action tags which tags are used for bean development?

a. jsp:useBean
b. jsp:setPoperty
c. jsp:getProperty
d. All mentioned above

36.
Which two interfaces does the javax.servlet.jsp package have?

a. JspPage
b. HttpJspPage
c. JspWriter
d. PageContext
e. Both A & B

37)   Which of the following is an advantage of the statement – Separation of business logic


from JSP ?

a. Custom Tags in JSP


b. JSP Standard Tag Library
c. All the above
d. None of the above

38)   JSPs eventually are compiled into Java servlets, you can do as much with JSPs as you can
do with Java servlets.

a. True
b. False

39)   How many jsp implicit objects are there and these objects are created by the web contain
that are available to all the jsp pages?
a. 8

b. 9
c. 10
d. 7

40)JavaServer
Pages often serve the same purpose as programs
implemented using the Common Gateway Interface (CGI)

a. True
b. False

41) Whichaction tags are used in JSP for developing web application
with Java Bean?

a. jsp:useBean
b. jsp:setProperty
c. jsp:getProperty
d. Both B & C

42) Which technology do we mix our business logic with the


presentation logic?
a. Servlet

b. JSP
c. Both A & B
d. None of the above

43) Which is the Microsoft solution for providing dynamic Web content?

a. ASP
b. JSP
c. Both A & B
d. None of the above

44) What is full form of JSP?

A.Java Service Provider

B.Java Service Pages

C.Java Server Provider

D.Java Server Pages

45) Which of the following is true about JSP?

1. JSP technology is used to create web application.

2. The JSP pages are not easier to maintain than Servlet.

3. JSP page consists of HTML tags and JSP tags.

A.1 & 2

B.1 & 3

C.2 & 3

D.All of the above

46) Which of the following are the life cycle method of jsp?

A.jspInit()

B._jspService()

C.jspDestroy()

D.All of the above

47) Request processing of JSP is done by calling which method?

A.jspInit()
B._jspService()

C.jspDestroy()

D._jspRequest()

48) Which of the following method helps in jsp page initialization?

A.jspInit()

B._jspService()

C.jspDestroy()

D.init()

49) Which of the following is correct about JSP?

1. JSP page is translated into Servlet.

2. JSP translator is a part of the web server which is responsible for translating the
JSP page into Servlet.

A.only 1

B.only 2

C.Both 1 & 2

D.None

50) Which of the following folder in JSP project contains web.xml file?

A.META-INF

B.WEB-INF

C.context-root

D.Any of A & B

51) Arrange in correct sequence of JSP life cycle.

1. Instantiation

2. Request processing

3. Initialization

4. Classloading
5. Compilation of JSP Page

6. Destroy

7. Translation of JSP Page

A.7-5-4-1-3-2-6

B.6-5-4-1-3-2-7

C.1-5-4-7-3-2-6

D.7-5-4-3-1-2-6

You might also like