How to include a File using directive and include action
<%@ include file = " "%>: - This is include directive. This directive has only one attribute named as file, which is used to include a file in the jsp page at the translation time. It is mainly used to include the static contents which doesn't need to be changed frequently. In jsp if we have to add a static content, whether it is a html, xml or any jsp page we should use include directive. The inclusion of the file is done at the translation time.
<jsp:include page = " ">:- This is known as the include standard action. This standard action is used to include a file at run time. This standard action is evaluated at the run time.
In this simple jsp program we have used both the include directive and the include standard action in the same jsp file.
The code of the program is given below:
<html> <head> <title> ssHow to include file at compile time and at run time</title> </head> <body> <h1>Directive Test Page</h1> <%@ include file = "include.html"%> <%@ include file ="Date.jsp"%> <h1>Using the include action</h1> <jsp:include page = "include.html"/> <jsp:include page ="Date.jsp"/> </body> <html> |
The output of the program is given below: