Important Web Design and Development Short Questions
Chapter: 38
Question 1:
What is the role of the Tag Library Descriptor (TLD) file in custom tags?
Answer:
The Tag Library Descriptor (TLD) file is an XML-based document that defines the custom tags available in a JSP application. It specifies the tag library version, JSP version, tag names, their corresponding tag handler classes, and any attributes associated with the tags. The TLD file provides the necessary information for the JSP container to process and correctly execute custom tags within JSP pages. It acts as a bridge between the JSP and the custom tag implementation.
Chapter: 39
Question 2:
What is the purpose of an error page in JSP?
Answer:
An error page in JSP allows for customizing error messages and maintaining a consistent look throughout an application. It can hide error details from users and handle uncaught exceptions, which are passed to the error page as an instance of java.lang.Throwable. This helps in providing a unified error handling mechanism.
Chapter: 39
Question 3:
How is a JSP page declared as an error page?
Answer:
A JSP page is declared as an error page by setting the isErrorPage attribute to true in the page directive. For instance, <%@page isErrorPage="true"%> makes the page an error page, and it can be designated to handle errors from other pages by using the errorPage attribute, like <%@page errorPage="error.jsp"%>.
Chapter: 39
Question 4:
What role does PersonDAO play in the Address Book application?
Answer:
The PersonDAO class encapsulates database logic for the Address Book application. It handles database connections and operations such as adding a new person to the database and retrieving person records based on search criteria. It uses SQL queries to interact with the database and manage PersonInfo objects.
Chapter: 39
Question 5:
Explain the flow of information in the Address Book application when adding a new person.
Answer:
In the Address Book application, the user inputs person information into addperson.jsp, which submits the data to saveperson.jsp. The saveperson.jsp page creates a PersonInfo object with the submitted data and uses PersonDAO to save this object to the database. After successful saving, saveperson.jsp displays a confirmation message and provides links to navigate to other pages.
Chapter: 39
Question 6:
Describe the difference between MVC Model 1 and Model 2 architectures.
Answer:
MVC Model 1 architecture involves JSP pages directly accessing JavaBeans and determining the next view based on hyperlinks or request parameters. This model often results in decentralized view selection and mixed code within JSPs. In contrast, MVC Model 2 (often implemented with frameworks like Apache Struts) introduces a controller to handle request processing and view selection centrally, leading to a more organized and maintainable structure by separating concerns more clearly.
Chapter: 39
Question 7:
What are the responsibilities of the Model, View, and Controller in the MVC architecture?
Answer:
In the MVC architecture, the Model represents the application's data and business logic. The View renders the data provided by the Model and specifies how it should be presented to the user. The Controller handles user interactions, translates them into actions on the Model, and selects the appropriate View to display the results. This separation of concerns allows for more manageable and scalable applications.
Chapter: 40
Question 8:
What is the main drawback of the page-centric approach in web applications?
Answer:
The page-centric approach mixes presentation, business, and data access logic, making maintenance difficult, scaling challenging, and resulting in code duplication.
Chapter: 40
Question 9:
How does the page-with-bean approach differ from the page-centric approach?
Answer:
The page-with-bean approach separates business logic into JavaBeans while still using JSPs for presentation. However, it does not fully separate all types of logic, which can still lead to some issues in maintenance and scaling.
Chapter: 40
Question 10:
What is the primary advantage of introducing a controller in MVC Model 2 architecture?
Answer:
The controller centralizes request dispatching, handles security checks, records logging information, and encapsulates incoming data for use by the backend MVC model, making the application more manageable and secure.