Posts

Showing posts from December 1, 2010

JSP Directive Taglib

Taglib Directive :-

Taglib Directive is used for include the tag from tag library. It defines the prefix for particular tag library.

Syntax of Taglib Directivs is :
<%@ taglib="URIToTagLibrary"  prefix="tagPrefix"%>

Example :

<%@ taglib uri="struts-bean.tld" prefix="bean"%>
<%@ taglib uri="struts-html.tld" prefix="html"%>
<%@ taglib uri="struts-logic.tld" prefix="logic"%>

<HTML>
<HEAD><title>Example Include Directive</title>
</HEAD>
<BODY>
<logic:empty>
           // some logic here …............
   </logic:empty>
</BODY>
</HTML>

Taglib is used to define the custom tag library and used the tag of this library through the tag prefix.

JSP Directives Include

Include Directive -

Include directives is used for include any static JSP or HTML file in the JSP page.

Syntax of Include Directives :-
<%@ include  file=”relative Path” %>

Example:-

First.jsp
<HTML>
<HEAD><title>Example Include Directive</title>
</HEAD>
<BODY>
 <%@ include file="/second.jsp" %>
</BODY>
</HTML>

second.jsp

<h1>Include me</h1>


More about :-
Include directive works at compilation time of JSP. It statically include JSP or HTML file. Mean content of included file written in the main servlet.

The included file might be open and available to all requests, or it might have security restrictions. The JSP page might be recompiled if the included file changes.

Recent Post

Recent Posts Widget