What is a directive?
A directive in JSP, represents an instruction to the translator to modify the structure of the auto generated servlet at the time of translation on behalf of the programmer. You have been already told that for each JSP, a servlet class is auto generated. Sometimes modifications are required in this servlet e.g. some extra packages need to be imported in it or it need to be inherited from a user defined class, or exceptions need to be managed in a specific way in it, etc. If this servlet were defined by the programmer, it could have been directly modified but it is generated from the JSP hence directives are provided to programmers so that they can ask the translator to customize the auto generated servlet on their behalf.
A JSP directive has following syntax:
Information to the translator is provided with the help of attributes. Different directives support different attributes.
JSP supports following three directives:
1. page: It is used by the JSP programmers to get the structure of auto generated servlet, modified according to their requirements.
2. include: It is used by the JSP programmers to get the contents of a file included to the response of JSP at the time of translation.
3. taglib: It is used by the JSP programmers to use custom tags in a JSP.
In the subsequent posts, use of all these directives is covered in detail.