Ajava W24
Ajava W24
addCookie(Cookie cookie)
sendRedirect(String location)
setContentType(String type)
getWriter()
• <jsp:useBean>
• <jsp:setProperty>
• <jsp:getProperty>
• <jsp:include>
• <jsp:forward>
• <jsp:param>
(b) 1) What are the advantages of Hibernate over JDBC?
2) What are the three types of text field’s tags provided by JSF?
• <h:inputText>
• <h:inputSecret>
• <h:inputTextarea>
(c) What is JDBC driver? Explain its role and compare various JDBC drivers.
JDBC Driver: A JDBC driver enables Java applications to connect and interact with databases.
Types:
Comparison:
Differences between TCP and UDP Sockets & Their Creation in Java:
1. ServletConfig
• Used for: Reading global parameters, resource paths, and for inter-servlet
communication.
Summary:
What is a Session?
A session is a mechanism to maintain state (data) about a user across multiple requests to a
web application.
HTTP is a stateless protocol, so sessions allow you to remember information (like user login)
during a user's interaction with the server.
Storage
Technique Description Pros Cons
Location
Works even if
URL Session ID is appended to the Client-side Exposes session ID
cookies
Rewriting URL (?sessionid=123) (URL) in URL
disabled
Memory
HttpSession Java-provided API that stores Most secure &
Server-side consumption on
API session data on the server flexible
server
• Use cookies or URL rewriting when session IDs need to be tracked across stateless
requests.
• Hidden fields are suitable for form-based applications with minimal session data.
Q.3 (a) What is the use of PreparedStatement? How will you use it?
Advantages:
(b) What is filter? How will you configure filter using deployment descriptor?
A Filter in Java EE is an object that performs filtering tasks on either the request to a
resource or on the response from a resource, or both.
Common Uses:
• Compression
• Input validation
(c) What is Java Bean? Demonstrate the use of JSP bean in web application.
1. Component-Based UI:
JSF provides a rich set of reusable UI components like forms, tables, and inputs that
simplify web development.
2. Event-Driven Programming:
Supports server-side event handling, similar to desktop applications (e.g., button click
events).
JSF helps build maintainable, scalable web applications with clean separation between UI
and logic.
If input is invalid, JSF prevents form submission and shows error messages.
(c) What are the cookies? Demonstrate the use of cookies in servlet for session
management.
Cookies are small pieces of data sent by the server to the client’s browser and stored there
to maintain user state across multiple requests.
• Cookies are created using new Cookie(name, value) and added via
response.addCookie().
3. Comprehensive Infrastructure:
Provides support for transaction management, security, data access, MVC, and more,
reducing development effort.
Spring Framework?
2. Using Annotations:
Spring provides flexible ways to inject dependencies, reducing manual object creation and
improving maintainability.
(c) What are the different Hibernate interfaces? Explain their role in brief.
Hibernate provides several key interfaces that help in managing the persistence of Java
objects to the database:
1. SessionFactory
2. Session
3. Transaction
4. Query
6. Interceptor