Unit 3 Java by HVS
Servlets & JSP
1. Explain the complete Servlet lifecycle. How do init(), service() and destroy()
methods work together in a web application? Include their role in memory
management and performance.
2. Compare and contrast GenericServlet and HttpServlet. Why is HttpServlet
preferred in web applications? Illustrate with an example.
3. Demonstrate how to build a web application where an HTML form sends data
to a Servlet, and the Servlet processes it and stores it in a database using JDBC.
Include sample code.
4. Explain the difference between ServletConfig and ServletContext. How do you
use them to read initialization parameters, and what are the scopes of each?
5. How are JSP scriptlets, declarations, and expressions different from each other?
Discuss with examples and also explain why using scriptlets is discouraged in
modern applications.
JSP Tags & Directives
6. Describe the usage and differences between JSP include directive (<%@
include %>) and jsp:include action tag. When should each be used?
7. How does the JSP lifecycle differ from the Servlet lifecycle? Discuss with a
diagram explaining translation, compilation, initialization, execution, and
cleanup stages.
Spring & Hibernate
8. Explain Spring's Inversion of Control (IoC) and Dependency Injection (DI).
How do they promote loose coupling in Java applications? Provide code
examples using annotations like @Component, @Autowired.
9. Discuss the Hibernate ORM lifecycle. Explain the roles of Session,
SessionFactory, and Transaction in CRUD operations. How is Hibernate
integrated into a Spring application?
10. Design a mini application using Spring and Hibernate that performs CRUD
operations on a Student entity. Explain how annotations are used to map the
class to a database table and how Spring manages transactions.