JSP Directive tutorial for Java Beginners

Directive is a type of Statement which can be used to give instruction to container about doing something special at @ page transalation time.

Directive can be divided in three types

  • Page
  • Include
  • Taglib

Page Directive

Syntax of Page Directive

<%@ page import="com.jbt.*"%>


Uses of Page Directive

Import Package

Page directive can be used to import single or double package.

Import Single Package

<%@ page import="com.jbt.*"%>

         Hello! <%= method() %>


Import Multiple Package 

<%@ page import="com.jbt.*,java.util.*"%>

       Hello! <%= method() %>. Time is <%new Date()%>


Taglib Directive

This directive is used to define tag libraries available to JSP.

Syntax of taglib Directive

<%@ taglib tagdir= "" prefix="" %>

 Uses of taglib Directive

taglib directive can be useful in case of Custom tags.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top Search