Important Web Design and Development Short Questions
Chapter: 32
Question 1:
What is a hidden form field and how is it used for session tracking?
Answer:
A hidden form field is an HTML element that stores information such as session IDs without affecting the appearance of the page. It is used to maintain session data between client and server.
Chapter: 32
Question 2:
How does the HttpSession API handle session tracking in Java?
Answer:
The HttpSession API handles session tracking by providing methods to create, retrieve, store, and manage session data. It abstracts the underlying mechanism of cookies or URL rewriting.
Chapter: 32
Question 3:
How do you retrieve a session object in a servlet?
Answer:
You retrieve a session object in a servlet by calling the getSession(true) method of HttpServletRequest, which returns the current session or creates a new one if it does not exist.
Chapter: 32
Question 4:
What method is used to store information in a session object?
Answer:
The setAttribute(String name, Object value) method is used to store information in a session object by associating a value with a specific name.
Chapter: 32
Question 5:
How can you check if a session is newly created or existing?
Answer:
You can check if a session is newly created or existing by using the isNew() method of HttpSession. If it returns true, the session is new; otherwise, it is an existing session.
Chapter: 32
Question 6:
What are encodeURL() and encodeRedirectURL() methods used for in session tracking?
Answer:
The encodeURL() method is used to rewrite URLs embedded in web pages to include session IDs, while encodeRedirectURL() is used for URLs in sendRedirect() calls to include session IDs when cookies are disabled.
Chapter: 33
Question 7:
What is the purpose of the presentation layer in a web application?
Answer:
The presentation layer provides the user interface for client interaction with the application. It is the part of the application that users directly see and interact with, such as web pages or forms. It handles the display and user input but does not contain business logic or data access code.
Chapter: 33
Question 8:
Describe the role of the business layer in a web application.
Answer:
The business layer, or service layer, implements the business logic of the application. It processes requests, performs operations like transaction management, and handles the core functionality of the application, separating these concerns from data access and presentation.
Chapter: 33
Question 9:
What does the data layer in a web application typically contain?
Answer:
The data layer consists of classes and objects that represent real-world business entities and manage data interactions. It includes components such as data access objects (DAOs) that encapsulate database interactions and facilitate operations like search, insert, update, and delete.
Chapter: 33
Question 10:
What is the purpose of the PersonInfo class in the address book case study?
Answer:
The PersonInfo class is used to hold and transport data about a person, including attributes like name, address, and phone number. It provides a structure to manage and transfer this data between the data layer and the presentation layer, with a method to output the data as a string.