Java Servlets and JSP Interview Questions and Answers - 1
Question: 1
What are Servlets?
Servlets are small program which execute on the web server.
They run under web server environment exploiting the functionalities of the web server.
Question: 2
What are the advantages of Servlets over CGI?
In CGI for every request there is a new process started which is quiet an overhead.
In CGI if there are 1000 request then CGI program is loaded in memory while in servlets there are 1000 thread and only one copy of the servlet class.
Question: 3
What is the difference between ServletContext and ServletConfig?
ServletConfig contains data from the servlet in the form of name and value pairs.
Using the ServletConfig we get reference to the ServletContext object.
ServletContext gives the servlet access to information about its runtime environment such as web server logging facilities, version info, URL details, web server attributes etc.
Question: 4
Can we explicitly destroy a servlet object?
No, we cannot destroy a servlet explicitly it’s all done by the container.
Even if you try calling the destroy method container does not respond to it.
Question: 5
What are different implicit objects of JSP?
pageContext: The pageContext object.
pageScope: A Map of all the objects that have page scope.
requestScope: A Map of all the objects that have request scope.
sessionScope: A Map of all the objects that have session scope.
applicationScope: A Map of all the objects that have application scope.
param: A Map of all the form parameters that were passed to your JSP page.
paramValues: HTML allows for multiple values for a single form parameter. This is a Map of all the parameters, just like param, but in this object the values are an array containing all of the values for a given parameter in the event that there’s more than one.
header: A Map of all the request headers.
headerValues: For the same reasons as paramValues, a headerValues object is provided.
cookie: A Map of all the cookies passed to your JSP. The value returned is a Cookie object.
initParam: A Map that maps context initialization parameter names to their parameter values.
- Java Servlets and JSP Interview Questions and Answers
- Java Servlet Interview Questions for Freshers Pdf
- Java Servlet Interview Questions and Answers for Experienced Pdf
- Top 150+ Java Servlet Interview Questions and Answers
- Java Concurrency Interview Questions and Answers
- Advanced Java Interview Questions and Answers
- Tricky Servlet Interview Questions and Answers
- 150+ Advanced Java Servlet API Interview Questions 2020-2021
Cloze Test Questions and Answers Pdf More
Cloze Test Questions for Competitive Exams 2026-2027 More
Cloze Test Questions for SBI PO Exam 2026-2027 Pdf More
Computer Fundamentals Tutorials 2026-2027 Pdf More
Verbal Ability Questions and Answers Pdf 2026-2027 More
7000+ Metallurgy Multiple Choice Questions and Answers More
Samacheer Kalvi 10th Social Civics Central Government Questions More
Samacheer Kalvi Class 11 Computer Ethics Questions More
Samacheer Kalvi 9th Social Endogenetic Processes Questions More
1000+ Petroleum Formation Evaluation Questions & Answers More