Important Web Design and Development Short Questions
Chapter: 35
Question 1:
What is the purpose of the pageContext implicit object?
Answer:
The pageContext implicit object provides a single point of access to various page attributes and allows for managing attributes and objects in a JSP page.
Chapter: 35
Question 2:
Explain the use of the exception implicit object in JSP.
Answer:
The exception implicit object represents the exception that was passed to an error page. It is used to handle errors and display relevant information when an exception occurs.
Chapter: 35
Question 3:
What are JSP directives and what purpose do they serve?
Answer:
JSP directives provide special processing instructions to the JSP container. They affect the overall structure of the resulting servlet and can specify page settings, include content from other resources, or define custom tag libraries.
Chapter: 35
Question 4:
How is the page directive used in JSP?
Answer:
The page directive provides high-level information about the servlet resulting from the JSP page. It can control imports, superclass, MIME type, session handling, and error page settings.
Chapter: 35
Question 5:
What is the difference between page and include directives in JSP?
Answer:
The page directive configures various aspects of the JSP page and servlet, while the include directive is used to include content from other files during the translation phase of the JSP, affecting the final output.
Chapter: 35
Question 6:
How does the include directive differ from including files via action elements?
Answer:
The include directive includes files at translation time, meaning it affects the JSP content before compilation. In contrast, action elements include files at request time, which allows for dynamic inclusion based on runtime conditions.
Chapter: 35
Question 7:
Provide an example of setting the content type in a JSP page.
Answer:
To set the content type to generate an Excel spreadsheet, you use <%@ page contentType="application/vnd.ms-excel" %>. This specifies that the output should be treated as an Excel file.
Chapter: 35
Question 8:
What are the JSP life cycle methods and their purposes?
Answer:
The JSP life cycle methods are jspInit(), _jspService(), and jspDestroy(). jspInit() initializes the JSP, _jspService() handles requests and generates responses, and jspDestroy() cleans up resources before the JSP is destroyed.
Chapter: 36
Question 9:
What is the purpose of controller.jsp in the provided example?
Answer:
controller.jsp redirects the user to either web.jsp or java.jsp based on the user's selection. It reads the parameter named page and uses response.sendRedirect() to navigate to the corresponding page.
Chapter: 36
Question 10:
What is the role of CourseDAO in the provided example?
Answer:
CourseDAO is a JavaBean responsible for encapsulating database connectivity and result processing logic. It retrieves course outlines from the database and returns them as an ArrayList of CourseOutlineBean objects.