JSP Directives Tutorial in Questions/Answers format for east understanding.
1. What is JSP directive?
- JSP directive directs or instructs the container how it should behave with a few aspects of JSP code processing.
- A JSP directive influences JSP code structure in general on the whole.
- A JSP directive gives the special instructions to container, the rules that can be applied to the whole JSP file.
- Directives dictate the processing of the whole JSP file. As per the directive, the container processes the JSP file.
- JSP directive provides special processing information to the container.
2. What is the general syntax of a directive?
The general syntax is:
<%@ directiveName attributeName="value assigned" %>
Ex: <%@ page import="java.util.*" %> where page is the directive name, import is the attribute name and java.util.* is the value assigned. We can treat attribute name and value as key/value pairs where key is attribute name and the value is the value assigned.
The XML equivalent syntax:
Ex: <jsp:directive.include file="local file" />
A directive can have a number of attributes. Sometimes values can be given comma separated.
3. How many types of directives exists?
There are three directives, JSP supports – page, include and taglib.
With all the 9 implicit objects, 4 implicit methods, 3 directives with their attributes and linking with JavaBeans you accept that writing server side code with JSP is very much easier than writing with Servlets. JSP takes less code than Servlets and code productivity increases.
Pass your comments and suggestions to improve the quality of this tutorial "JSP Directives Tutorial".