Java MCQ: Which directive is used to include a file in a JSP page?
a) <%@ include %>
b) <%@ file %>
c) <%@ page %>
d) <%@ directive %>
Answer:
a) <%@ include %>
Explanation:
The <%@ include %>
directive is used to include a file in a JSP page. This directive allows you to insert the content of one JSP file into another at compile time, making it useful for reusing code and creating templates.
Here’s an example of using the include
directive:
<%@ include file="header.jsp" %>
In this example, the content of header.jsp
is included at the location of the include
directive in the main JSP page. This inclusion happens during the JSP compilation process.
The include
directive is commonly used for including header, footer, and navigation files that are shared across multiple JSP pages.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html