
- 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 IV
Q 1 - Which of the following is true about Cleanup phase in JSP life cycle?
B - The jspDestroy() method is the JSP equivalent of the destroy method for servlets.
Answer : C
Explaination
The destruction phase of the JSP life cycle represents when a JSP is being removed from use by a container.The jspDestroy() method is the JSP equivalent of the destroy method for servlets.
Q 2 - Which of the following is true about <jsp:useBean> action?
Answer : C
Explaination
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. useBean is used to load java beans in jsp page.
Q 3 - Which of the following is true about <jsp:setProperty> action?
A - The setProperty action sets the properties of a Bean.
B - The Bean must have been previously defined before using setProperty action.
Answer : C
Explaination
The setProperty action sets the properties of a Bean. The Bean must have been previously defined before this action.
Q 4 - Which of the following is true about <jsp:getProperty> action?
Answer : C
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 5 - Which of the following is true about <jsp:forward> action?
A - The forward action terminates the action of the current page.
Answer : C
Explaination
The forward action terminates the action of the current page and forwards the request to another resource such as a static page, another JSP page, or a Java Servlet.
Q 6 - Which of the following is true about response.sendRedirect(url)?
A - The sendRedirect sends HTTP temporary redirect response to the browser.
Answer : C
Explaination
sendRedirect sends HTTP temporary redirect response to the browser, and browser creates a new request to go the redirected page.
Q 7 - What JSTL stands for?
Answer : A
Explaination
JSTL, JavaServer Pages Standard Tag Library is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications.
Q 8 - What is Internationalization?
A - Internationalization means creating international content on a website.
C - Internationalization refers to creating local content on a website.
Answer : B
Explaination
Internationalization means enabling a web site to provide different versions of content translated into the visitor's language or nationality.
Q 9 - What is Localization?
A - Localization refers to creating local content on a website.
B - Localization refers to adding locale related information to a website.
Answer : C
Explaination
Localization means adding resources to a web site to adapt it to a particular geographical or cultural region for example Hindi translation to a web site.
Q 10 - Which of the following is true about locale?
Answer : C
Explaination
Locale is a particular cultural or geographical region. It is usually referred to as a language symbol followed by a country symbol which are separated by an underscore. For example "en_US" represents english locale for US.
Q 11 - What is difference between <%-- comment --%> and <!-- comment -->?
A - <%-- comment --%> is JSP comment. <!-- comment --> is an HTML comment.
B - <%-- comment --%> is ignored by JSP container.
Answer : D
Explaination
Answer : A
Explaination
Yes. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries.
Answer : A
Explaination
Yes. However, unlike Servlet, you are not required to implement HTTP-protocol specific methods like doGet() or doPost() within your JSP page. You can obtain the data for the FORM input elements via the request implicit object within a scriptlet or expression.
Answer : B
Explaination
No. You are supposed to make use of only a JSPWriter object (given to you in the form of the implicit object out) for replying to clients.
Q 15 - How to pass information from JSP to included JSP?
Answer : A
Explaination
Using <%jsp:param> tag you can pass information from JSP to included JSP.
Q 16 - 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.
Answer : B
Explaination
The <c:set > tag is JSTL-friendly version of the setProperty action. The tag is helpful because it evaluates an expression and uses the results to set a value of a JavaBean or a java.util.Map object.
Q 17 - What is the use of <c:remove > tag?
A - It removes a item from a list
Answer : C
Explaination
The <c:remove > tag removes a variable from either a specified scope or the first scope where the variable is found (if no scope is specified).
Q 18 - What is the use of <c:catch> tag?
A - to catch any Throwable that occurs in its body and optionally exposes it.
Answer : A
Explaination
The <c:catch> tag catches any Throwable that occurs in its body and optionally exposes it. Simply it is used for error handling and to deal more gracefully with the problem.
Q 19 - What is the use of <c:if> tag?
A - It is used to check if jsp tag library is enabled or not.
Answer : B
Explaination
The <c:if> tag evaluates an expression and displays its body content only if the expression evaluates to true.
Q 20 - Which of the following is true about <c:choose> tag?
B - The <c:choose> tag has <c:when> tags.
Answer : D
Explaination
The <c:choose> works like a Java switch statement in that it lets you choose between a number of alternatives. Where the switch statement has case statements, the <c:choose> tag has <c:when> tags. A a switch statement has default clause to specify a default action and similar way <c:choose> has <otherwise> as default clause.
Q 21 - Which of the following is true about <c:forEach > tag?
B - The <c:forEach > is used to iterate over a list of items in jsp.
Answer : C
Explaination
The <c:forEach > tag exists as a good alternative to embedding a Java for, while, or do-while loop via a scriptlet.
Q 22 - Which of the following is true about <c:param> tag?
A - The <c:param> tag allows proper URL request parameter to be specified with URL.
B - The <c:param> tag does any necessary URL encoding required
Answer : C
Explaination
The <c:param> tag allows proper URL request parameter to be specified with URL and it does any necessary URL encoding required.
Q 23 - Which of the following is true about <c:redirect> tag?
B - The <c:redirect > tag supports context-relative URLs.
Answer : D
Explaination
The <c:redirect > tag redirects the browser to an alternate URL by providing automatically URL rewriting, it supports context-relative URLs, and it supports the <c:param> tag.
Q 24 - Which of the following is true about <c:url> tag
A - The <c:url> tag formats a URL into a string and stores it into a variable.
B - The <c:url> tag automatically performs URL rewriting when necessary.
Answer : C
Explaination
The <c:url> tag formats a URL into a string and stores it into a variable. This tag automatically performs URL rewriting when necessary.
Q 25 - What's the difference between JavaBeans and taglib directives?
B - Custom tags are used to implement actions and JavaBeans are used to present information.
Answer : A
Explaination
JavaBeans and taglib fundamentals were introduced for reusability. But following are the major differences between them −
Taglibs are for generating presentation elements while JavaBeans are good for storing information and state.
Use custom tags to implement actions and JavaBeans to present information.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | C |
2 | C |
3 | C |
4 | C |
5 | C |
6 | C |
7 | A |
8 | B |
9 | C |
10 | C |
11 | D |
12 | A |
13 | A |
14 | B |
15 | A |
16 | B |
17 | C |
18 | A |
19 | B |
20 | D |
21 | C |
22 | C |
23 | D |
24 | C |
25 | A |