Directives provide instructions to the JSP container and affect compiling of the JSP page.
Though there are mainly three types of directives named as ‘page directive’, ‘include directive, and ‘taglib directive’, but I am going to cover few more along with them.
[table caption=”JSP Directives Table” width=”750″ colwidth=”10|50|50|50″ colalign=”left|left|left|left”]
1,JSP Expression,<%= expression %>, expression is evaluated and placed in output.
2,JSP Scriplets,<% code %>, code is inserted in service() method.
3,JSP Declaration,<%! code %>, code is inserted in the body of servlet class – outside of service method.
4,JSP Page Directive,<%@ page att=”val” %>, Directions to the servlet engine about general setup.
5,JSP Include Directive,<%@ include file=”url” %>, A file on the local system to be included when JSP page is translated into servlet.
6,JSP Comment,<%– Comment –%>, Comments ignored when JSP converted into Servlet.
7,JSP Taglib,<%@ taglib … %>, declares a tag library containing custom actions – used in the page.