
- Basic JSP Tutorial
- JSP - Home
- JSP - Overview
- JSP - Environment Setup
- JSP - Architecture
- JSP - Lifecycle
- JSP - Syntax
- JSP - Directives
- JSP - Actions
- JSP - Implicit Objects
- JSP - Client Request
- JSP - Server Response
- JSP - Http Status Codes
- JSP - Form Processing
- JSP - Writing Filters
- JSP - Cookies Handling
- JSP - Session Tracking
- JSP - File Uploading
- JSP - Handling Date
- JSP - Page Redirect
- JSP - Hits Counter
- JSP - Auto Refresh
- JSP - Sending Email
- Advanced JSP Tutorials
- JSP - Standard Tag Library
- JSP - Database Access
- JSP - XML Data
- JSP - Java Beans
- JSP - Custom Tags
- JSP - Expression Language
- JSP - Exception Handling
- JSP - Debugging
- JSP - Security
- JSP - Internationalization
- JSP Useful Resources
- JSP - Questions and Answers
- JSP - Quick Guide
- JSP - Useful Resources
- JSP - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
JSP Mock Test
This section presents you various set of Mock Tests related to JSP Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

JSP Mock Test II
Q 1 - Which of the following attributes are mandatory in <jsp:getProperty /> tag?
Answer : A
Explaination
The getProperty action is used to retrieve the value of a given property and converts it to a string, and finally inserts it into the output.
Q 2 - Which of the following attributes are mandatory in <jsp:setProperty /> tag?
Answer : A
Explaination
The setProperty action sets the properties of a Bean. The Bean must have been previously defined before this action.
Q 3 - Which of the following attributes are mandatory in <jsp:useBean /> tag?
Answer : B
Explaination
The useBean action first searches for an existing object utilizing the id and scope variables. If an object is not found, it then tries to create the specified object using class.
Q 4 - Which of the following are the valid scopes in JSP?
A - request, page, session, application
B - request, page, session, global
Answer : A
Explaination
The scope attribute identifies the lifecycle of the Action element. It has four possible values: (a) page, (b) request, (c) session, and (d) application.
Q 5 - Which of the following is true about request 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.
Answer : C
Explaination
Object created with request scope are accessible only from the pages which are processing the same request. Object data is available to another page in case of forward.
Q 6 - Which of the following is true about page 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.
Answer : A
Explaination
Object created with request scope are accessible only from the page which they are created. Object data gets lost once response is returned or request is forwarded.
Q 7 - 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.
Answer : B
Explaination
Object created with request scope are accessible only from the pages which are in same session. Object data is available till session is alive.
Q 8 - Which of the following is true about application 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.
Answer : D
Explaination
Object created with request scope are accessible only from the pages which resides in same application. Object data is global and is available to all pages.
Q 9 - Which of the following is true about language attribute?
A - The language attribute indicates the programming language used in scripting the servlet.
B - The language attribute indicates the programming language used in scripting the html page.
C - The language attribute indicates the programming language used in scripting the JSP page.
Answer : C
Explaination
The language attribute indicates the programming language used in scripting the JSP page.
Q 10 - Which of the following attribute is used to have uncaught run-time exceptions automatically forwarded to an error processing page?
Answer : B
Explaination
<%@ page errorPage="error.jsp" %>
It will redirect the browser to the JSP page error.jsp if an uncaught exception is encountered during request processing.
Q 11 - Which of the following attribute is used to mark a page as error processing page?
Answer : A
Explaination
<%@ page isErrorPage="true" %>
Within jsp, indicate that it is an error-processing page, using the above directive.
Q 12 - Which of the following attributes are used in <jsp:include /> tag?
Answer : B
Explaination
<jsp:include /> lets you insert files into the page being generated. The syntax looks like this −
<jsp:include page="relative URL" flush="true" />
Where page is the relative URL of the page to be included. Flush is the boolean attribute the determines whether the included resource has its buffer flushed before it is included.
Q 13 - Which of the following is not a jsp directive?
Answer : C
Explaination
scriptlet is not a jsp directive.
Q 14 - Which of the following is an implicit object?
Answer : A
Explaination
pageContext is an implicit object.
Answer : B
Explaination
isErrorPage is required to be set true, it is false by default.
Q 16 - out is instance of which class?
A - javax.servlet.jsp.JspWriter
Answer : A
Explaination
The out implicit object is an instance of a javax.servlet.jsp.JspWriter object and is used to send content in a response.
Q 17 - application is instance of which class?
Answer : A
Explaination
The application object is direct wrapper around the ServletContext object for the generated Servlet and in reality an instance of a javax.servlet.ServletContext object.
Q 18 - config is instance of which class?
A - javax.servlet.ServletContext
Answer : B
Explaination
The config object is an instantiation of javax.servlet.ServletConfig and is a direct wrapper around the ServletConfig object for the generated servlet.
Q 19 - pageContext is instance of which class?
A - javax.servlet.ServletContext
B - javax.servlet.ServletConfig
Answer : C
Explaination
The pageContext object is an instance of a javax.servlet.jsp.PageContext object. The pageContext object is used to represent the entire JSP page.
Q 20 - Which of the following method can be used to read a form parameter in JSP?
Answer : A
Explaination
You call request.getParameter() method to get the value of a form parameter.
Q 21 - Which of the following method can be used to read a multiple values with same name, for example check box selections?
Answer : C
Explaination
You call request.getParameterValues() method to get the value of a form parameter if the parameter appears more than once and returns multiple values.
Q 22 - Which of the following method can be used to read parameters names?
Answer : C
Explaination
You call request.getParameterNames() method to get the names of all the parameters passed.
Q 23 - Which of the following method can be used to read binary data stream coming from the client?
Answer : A
Explaination
You call request.getInputStream() method to read binary data stream coming from the client for example, image file uploaded.
Q 24 - What is true about filters?
Answer : C
Explaination
JSP Filters are Java classes that can be used in JSP Programming for both of the above purposes.
Q 25 - Where filters are defined?
A - Filters are defined in the deployment descriptor file web.xml.
Answer : A
Explaination
Filters are defined in the deployment descriptor file web.xml and then mapped to either servlet or JSP names or URL patterns in your application's deployment descriptor.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | A |
2 | A |
3 | B |
4 | A |
5 | C |
6 | A |
7 | B |
8 | D |
9 | C |
10 | B |
11 | A |
12 | B |
13 | C |
14 | A |
15 | B |
16 | A |
17 | A |
18 | B |
19 | C |
20 | A |
21 | C |
22 | C |
23 | A |
24 | C |
25 | A |