JSP-Servlet Interview Questions You'll Most Likely Be Asked
()
About this ebook
- 280 JSP-Servlet Interview Questions
- 78 HR Interview Questions
- Real life scenario based questions
- Strategies to respond to interview questions
- 2 Aptitude Tests
JSP-Servlet Intervie
Other titles in JSP-Servlet Interview Questions You'll Most Likely Be Asked Series (30)
CORE JAVA Interview Questions You'll Most Likely Be Asked Rating: 4 out of 5 stars4/5SQL Server Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsAdvanced JAVA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSoftware Testing Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsData Structures & Algorithms Interview Questions You'll Most Likely Be Asked Rating: 1 out of 5 stars1/5C & C++ Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsJSP-Servlet Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsAdvanced C++ Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsC# Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsHibernate, Spring & Struts Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsCCNA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsHadoop BIG DATA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsJava / J2EE Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsORACLE PL/SQL Interview Questions You'll Most Likely Be Asked Rating: 5 out of 5 stars5/5Automated Software Testing Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSAP HANA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsPython Interview Questions You'll Most Likely Be Asked Rating: 2 out of 5 stars2/5JavaScript Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsOperating Systems Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsAdvanced SAS Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsBase SAS Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsIBM WebSphere Application Server Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsLinux System Administrator Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsUNIX Shell Programming Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSAS Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSAS Programming Guidelines Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSelenium Testing Tools Interview Questions You'll Most Likely Be Asked: Second Edition Rating: 0 out of 5 stars0 ratingsJava/J2EE Design Patterns Interview Questions You'll Most Likely Be Asked: Second Edition Rating: 0 out of 5 stars0 ratingsCloud Computing Interview Questions You'll Most Likely Be Asked: Second Edition Rating: 0 out of 5 stars0 ratings
Read more from Vibrant Publishers
GMAT Analytical Writing: Solutions to the Real Argument Topics: Test Prep Series Rating: 4 out of 5 stars4/5Operations and Supply Chain Management Essentials You Always Wanted To Know: Self Learning Management Rating: 5 out of 5 stars5/5GRE Words In Context: The Complete List: Test Prep Series Rating: 5 out of 5 stars5/5Digital SAT Reading and Writing Practice Questions: Test Prep Series Rating: 5 out of 5 stars5/5GRE Master Wordlist: 1535 Words for Verbal Mastery: Test Prep Series Rating: 4 out of 5 stars4/5GRE Reading Comprehension: Detailed Solutions to 325 Questions: Test Prep Series Rating: 5 out of 5 stars5/5Leadership Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsData Analytics Essentials You Always Wanted To Know: Self Learning Management Rating: 4 out of 5 stars4/5HR Analytics Essentials You Always Wanted To Know: Self Learning Management Rating: 4 out of 5 stars4/5Organizational Behavior Essentials You Always Wanted To Know: Self Learning Management Rating: 3 out of 5 stars3/5GRE Analytical Writing: Solutions to the Real Essay Topics - Book 2: Test Prep Series Rating: 5 out of 5 stars5/5GRE Text Completion and Sentence Equivalence Practice Questions: Test Prep Series Rating: 4 out of 5 stars4/5GRE Analytical Writing: Solutions to the Real Essay Topics - Book 1: Test Prep Series Rating: 5 out of 5 stars5/5Python Essentials You Always Wanted to Know: Self Learning Management Rating: 5 out of 5 stars5/5Core Java Interview Questions You'll Most Likely Be Asked: Job Interview Questions Series Rating: 4 out of 5 stars4/5Principles of Management Essentials You Always Wanted To Know: Self Learning Management Rating: 5 out of 5 stars5/5Social Media Marketing Essentials You Always Wanted To Know: Self Learning Management Rating: 4 out of 5 stars4/5Sales Management Essentials You Always Wanted To Know: Self Learning Management Rating: 4 out of 5 stars4/5Writing Impressive College Essays: Test Prep Series Rating: 0 out of 5 stars0 ratingsHR Interview Questions You'll Most Likely Be Asked: Job Interview Questions Series Rating: 0 out of 5 stars0 ratingsOrganizational Development Essentials You Always Wanted To Know: Self Learning Management Rating: 4 out of 5 stars4/5Winning Strategies For ACT Essay Writing: With 15 Sample Prompts: Test Prep Series Rating: 5 out of 5 stars5/5Blockchain Essentials You Always Wanted To Know: Self Learning Management Rating: 0 out of 5 stars0 ratingsBusiness Strategy Essentials You Always Wanted To Know: Self Learning Management Rating: 5 out of 5 stars5/5Time Management Essentials You Always Wanted To Know: Self Learning Management Rating: 4 out of 5 stars4/5GRE Analytical Writing Supreme: Solutions to the Real Essay Topics: Test Prep Series Rating: 5 out of 5 stars5/5Personal Finance Essentials You Always Wanted to Know: Self Learning Management Rating: 3 out of 5 stars3/5Financial Management Essentials You Always Wanted to Know: 5th Edition: Self Learning Management Rating: 5 out of 5 stars5/5GRE Verbal Reasoning Supreme: Study Guide with Practice Questions: Test Prep Series Rating: 4 out of 5 stars4/5
Related to JSP-Servlet Interview Questions You'll Most Likely Be Asked
Titles in the series (33)
CORE JAVA Interview Questions You'll Most Likely Be Asked Rating: 4 out of 5 stars4/5SQL Server Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsAdvanced JAVA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSoftware Testing Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsData Structures & Algorithms Interview Questions You'll Most Likely Be Asked Rating: 1 out of 5 stars1/5C & C++ Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsJSP-Servlet Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsAdvanced C++ Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsC# Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsHibernate, Spring & Struts Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsCCNA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsHadoop BIG DATA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsJava / J2EE Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsORACLE PL/SQL Interview Questions You'll Most Likely Be Asked Rating: 5 out of 5 stars5/5Automated Software Testing Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSAP HANA Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsPython Interview Questions You'll Most Likely Be Asked Rating: 2 out of 5 stars2/5JavaScript Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsOperating Systems Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsAdvanced SAS Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsBase SAS Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsIBM WebSphere Application Server Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsLinux System Administrator Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsUNIX Shell Programming Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSAS Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSAS Programming Guidelines Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsSelenium Testing Tools Interview Questions You'll Most Likely Be Asked: Second Edition Rating: 0 out of 5 stars0 ratingsJava/J2EE Design Patterns Interview Questions You'll Most Likely Be Asked: Second Edition Rating: 0 out of 5 stars0 ratingsCloud Computing Interview Questions You'll Most Likely Be Asked: Second Edition Rating: 0 out of 5 stars0 ratings
Related ebooks
Dynamic Memory Sure Success in Interviews Rating: 0 out of 5 stars0 ratingsMastering Time Management: Time management Interview Questions and Answers Rating: 0 out of 5 stars0 ratingsHow to Set up Your I.T. System Rating: 0 out of 5 stars0 ratingsThe World's Shortest Management Course Rating: 0 out of 5 stars0 ratings9 Ways to Hire Great Programmers Rating: 0 out of 5 stars0 ratingsWordPress 3.0 jQuery Rating: 0 out of 5 stars0 ratingsHuman Resource Management System Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratingsTechnical Support Engineering Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratingsHibernate, Spring & Struts Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsMicrosoft Exchange 2013 Cookbook Rating: 0 out of 5 stars0 ratingsManaging a project with Microsoft Project 2010 Rating: 2 out of 5 stars2/5Incident Management Report The Ultimate Step-By-Step Guide Rating: 0 out of 5 stars0 ratingsHow to Cope with Unemployment, Find a Job in Any Economy, and Save Money Rating: 0 out of 5 stars0 ratingsLearning VMware vRealize Automation: Learn the fundamentals of vRealize Automation to accelerate the delivery of your IT services Rating: 0 out of 5 stars0 ratingsIBM WebSphere Application Server Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsStrategic Hiring: The Dynamic Manager’s Handbook On How To Hire The Best Employees Rating: 0 out of 5 stars0 ratingsAdvanced SAS Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsC# Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsThe HR Professionals Guide to the Best Interview Questions Rating: 0 out of 5 stars0 ratings101 Great Answers to the Toughest Interview Questions Rating: 4 out of 5 stars4/5The Art Of Interviews Rating: 0 out of 5 stars0 ratingsInnovative Interview Questions You'll Most Likely Be Asked: Job Interview Questions Series Rating: 0 out of 5 stars0 ratingsSecrets Revealed: Land the Job of Your Dreams: Premier Guide ~ Create Your Winning Resume and Interview! Rating: 0 out of 5 stars0 ratingsJob Interview Questions And Answers Rating: 0 out of 5 stars0 ratingsJob Interview: Dominate the Toughest Job Interview Questions with Perfect Answers Rating: 5 out of 5 stars5/5Getting an Information Security Job For Dummies Rating: 0 out of 5 stars0 ratings70+ Interview Questions and How To Answer Them ALL Rating: 0 out of 5 stars0 ratingsMastering The Job Interview: 70 Essential Questions and Answers Rating: 0 out of 5 stars0 ratings
Programming For You
Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5PYTHON PROGRAMMING Rating: 4 out of 5 stars4/5Python Data Structures and Algorithms Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Beginning Programming with C++ For Dummies Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5JavaScript All-in-One For Dummies Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Excel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsPython 3 Object Oriented Programming Rating: 4 out of 5 stars4/5Godot from Zero to Proficiency (Foundations): Godot from Zero to Proficiency, #1 Rating: 5 out of 5 stars5/5Learn NodeJS in 1 Day: Complete Node JS Guide with Examples Rating: 3 out of 5 stars3/5Learn Python in 10 Minutes Rating: 4 out of 5 stars4/5Python Games from Zero to Proficiency (Beginner): Python Games From Zero to Proficiency, #1 Rating: 0 out of 5 stars0 ratings
Reviews for JSP-Servlet Interview Questions You'll Most Likely Be Asked
0 ratings0 reviews
Book preview
JSP-Servlet Interview Questions You'll Most Likely Be Asked - Vibrant Publishers
JSP Servlet
Interview Questions
You'll Most Likely Be Asked
Job Interview Questions Series
www.vibrantpublishers.com
*****
JSP Servlet Interview Questions You'll Most Likely Be Asked
Copyright 2021, By Vibrant Publishers, USA. All rights reserved. No part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior permission of the publisher.
This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. The author has made every effort in the preparation of this book to ensure the accuracy of the information. However, information in this book is sold without warranty either expressed or implied. The Author or the Publisher will not be liable for any damages caused or alleged to be caused either directly or indirectly by this book.
Vibrant Publishers books are available at special quantity discount for sales promotions, or for use in corporate training programs. For more information please write to [email protected]
Please email feedback / corrections (technical, grammatical or spelling) to [email protected]
To access the complete catalogue of Vibrant Publishers, visit www.vibrantpublishers.com
*****
Table of Contents
1. Servlet
2. Servlet Lifecycle
3. Servlet Reloading / Loading
4 . Servlet Context
5. Session Management
6. Session Object
7. Servlet Event Listeners
8. Servlet Filter
9. JSP and Servlet
10. JSP Lifecycle and Methods
11. JSP Implicit Object
12. JSP Tags
13. JSP Actions
14. GetParameter()
15. Response Object
16. PrintWriter, JspWriter
17. Miscellaneous
HR Questions
Index
*****
Servlet
1: What is the difference between JSP and Java Servlet?
Answer:
JSP is a web scripting language that’s embedded inside the HTML code for a page and is based on Java. Servlets are java programs that are written and compiled in a proper Java environment. You can write dynamic HTML content in Servlets. JSP is a view whereas Servlets are controllers. JSP ultimately compiles into a servlet before it runs and hence, is a little slower compared to the Servlets. JSP is preferred when there’s very little server-side data manipulation required. If there’s a lot of data manipulation involving complex business functions, the Servlets are preferred. JSP is easier to write as the scripting within the HTML code is easier to manage. With Javascript, JSP can easily manage client-side matters whereas the Servlets are purely server-side.
2: Explain the tasks of a Servlet.
Answer:
A Servlet’s tasks include reading all implicit and explicit data sent by the client, process the requests at the server-side to generate results, and send this result as implicit or explicit to the client. Explicit input data would be form data as input or selected by the client. This is explicitly input or selected by the client to retrieve some information or to provide some information which has to be saved in the database. Implicit input data would be the request headers or other hidden elements such as status codes etc. which are set at the client’s side while selecting some option. Explicit output would be the HTML displayed on the client’s browser with the information requested. Implicit output would be the request headers and status codes sent by the server.
3: Explain Servlet Mapping.
Answer:
Servlet mapping is the method used to map the servlet classes and packages to a particular web application. It is done using the
Here, the
4: Explain what happens when a client requests a jsp page from the browser.
Answer:
When the client browser tries to access a particular jsp page, the corresponding jsp server is identified from the URL first. The jsp server checks for an existing compiled servlet corresponding to the requested page. If the page is not found or if the class is older than the latest jsp page, it has to be compiled first. The requested jsp page’s java components are compiled into servlet and forwarded to the servlet engine which is a part of the web server. The Servlet engine loads the compiled servlet class and executes the same. The result is written as static HTML content and passed on to the web server as an HTTP response. It finally reaches the browser which displays the HTML content to the user.
5: Why do we need JSP when Servlets are there?
Answer:
Even when you are writing JSP code, you know that ultimately it is going to get converted into java code and a servlet. The jsp page’s server-side scripts are compiled into java servlet class and that’s what is executed. We can code a java servlet instead. But the main advantage of jsp pages is that they are much simpler to code and implement. The HTML tags will be a real pain to write using the java println statement. Instead, the required minimal scripts are included between the HTML tags, making the jsp pages easier to maintain. When using JSP, you can get the user interface coded separately and just include the required java elements within the scripting tags.
6: What is SSI (Server Side Includes)?
Answer:
Server side includes (SSI) are the directives and servlet code embedded within HTML pages to add some dynamically generated data retrieved from the server into the HTML pages.
SSI
Username is
It will take the id from the HTML page and retrieve the username from the servlet file.
7: How do servlets handle multiple requests simultaneously?
Answer:
The Servlet container will create a single instance and multiple threads for a servlet. When multiple requests arrive simultaneously, the container synchronizes these requests by creating a new thread for each request and calls the service() method. The Service() method will be called for each request so as to handle these multiple requests.
8: What is the difference between GenericServlet and HttpServlet?
Answer:
The differences between GenericServlet and HttpServlet are:
a) HttpServlet is for the HTTP protocol requests and is protocol dependent. It is extended from GenericServlet and inherits all the properties of a GenericServlet.
b) GenericServlet is for all protocols such as FTP and is a protocol independent. It is sufficient to implement service() method to implement genericservlet. It implements the LOG method of ServletContext interface.
9: If we need to perform a login validation before hitting our application servlet, what could be done?
Answer:
To perform a login validation, we can use ServletFilter. This is mainly to provide authorization for all the pages given in the application. Only a single filter is needed to enable the authorization.
10: Who is responsible to create a servlet instance?
Answer:
Web container is responsible to create a servlet instance.
11: What is Servlet Collaboration?
Answer:
Servlet Collaboration refers to the communication between servlets. Information can be shared among the servlets through some method invocations, such as:
a) RequestDispatcher (forward() or include())
b) response.sendRedirect()
c) System.getProperties().put(name
, ABC
) and
String s1 = System.getProperty(name
);
d) ServletContext
12: What is the architecture of a Servlet Interface?
Answer:
The architecture of a Servlet Interface is as given below:
Servlets >> GenericServlet >> HttpServlet >> CustomServlet
javax.servlet is the package which contains interfaces and classes.
13: What are the objects a servlet would receive during client interaction?
Answer:
A servlet would receive two objects during client interaction. They are:
a) ServletRequest interface
b)ServletRespose interface
14: Why do we not have constructors in servlets?
Answer:
The init() method is used for instantiating the servlets instead of constructors. The servlet container will take care of instantiating the servlet hence an explicit constructor is not required. Initialization code can be placed within init() method as we would have placed within the constructor. It will be called by the container once it has loaded the servlet at the first request.
15: How would you get the real path of the current servlet?
Answer:
We can retrieve the current servlet’s real path using getRealPath() method:
System.out.println(request.getRealPath(request.getServletPath());
16: How would you call one servlet from another?
Answer:
A servlet can be called from another:
a) Using RequestDispatcher
b) Using URLConnection or HttpClient
c) Using response.sendRedirect
17: What are the different types of Servlets available?
Answer:
The different types of Servlets available are:
a) Generic Servlet
b) HttpServlet
18: Explain about HttpServlet and its methods.
Answer:
Httpservlet extends the GenericServlet class. A servlet class which implements HttpServlet class should override one of the below methods.
The methods of httpservlet are:
a) doGet()
b) doPost()
c) doPut()
d) doDelete()
e) getServletInfo()
f) service()
The service() method is not normally overridden since it dispatches the HTTP requests automatically to these appropriate methods. If service() method are to be overridden, doGet() or doPost() methods should also be invoked explicitly from the overridden service() method else super.service() method should be invoked from the overridden service() method to preserve the original service() method’s functionality.
19: What are the advantages of Servlets?
Answer:
The advantages of Servlets are:
a) Platform independent: Once it is compiled, it can be run in any web server
b) Threadsafe: Different threads are created for different requests in a multithreaded environment
20: Name the servers available for deploying Servlets.
Answer:
The various servers available for deploying Servlets are:
a) Netscape
b) IBM Websphere
c) Oracle
d) Tomcat webserver
e) Apache
f) Weblogic
21: What would happen if I want to use the Servlet 2.1 API instead of Servlet2.0 API?
Answer:
If we use Servlet 2.1 API instead of Servlet2.0 API, servlet to servlet communication will not work as the communication using servletcontext methods like getServlet() and getServlets() have been deprecated. It will return null.
22: How would you avoid IllegalStateException in Servlet?
Answer:
IllegalStateException in Servlet happens when the servlet attempts to write into the response object (output stream) after it has been redirected or committed. It can be avoided using a return statement immediately after response.sendRedirect() or forward() methods. For example,
public void doGet(HttpServletRequestreq, HttpServletResponseresp) throws ServletException, IOException {
if(s1.equals(s2)) {
response.sendRedirect(login.jsp
);
return;
}
}
23: How