JSP Directives Tutorial


JSP Directives Tutorial in Questions/Answers format for east understanding.

1. What is JSP directive?

  1. JSP directive directs or instructs the container how it should behave with a few aspects of JSP code processing.
  2. A JSP directive influences JSP code structure in general on the whole.
  3. A JSP directive gives the special instructions to container, the rules that can be applied to the whole JSP file.
  4. Directives dictate the processing of the whole JSP file. As per the directive, the container processes the JSP file.
  5. 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".

Leave a Comment

Your email address will not be published.