In this section, we will discuss about how to display current date & time using custom(user define) tag.JSP Custom Tags :
Provide a mechanism to a Web programmer to reuse and encapsulate complex recurring code in a JSP application.
Provide simplicity and reusability of Java code.
Enable you to perform various functions, such as:
Accessing all implicit variables of a JSP page, such as request, response, in, and out.
Modifying the response generated by a calling JSP page.
The various types of custom tags that you can develop in JSP are :
<td: welcome color=?blue?></td:welcome>
Nested tags: Refer to the set of custom tags in which one custom tag encloses one or more custom tags. The following code snippet shows a nested custom tag:
<td1:ifTag condition ?<%=eval>? >
The expression evaluates to true
Development of Custom Tag :
To develop a custom tag, you need to perform following steps:
Develop a tag handler or class file(.java)
Develop the Tag Library Descriptor (TLD) file
Include the Tag Library in a JSP page
In this Example, Current date & time will display using custom tag.
Tag Handler File :
Build a class that implements the
javax.servlet.jsp.tagext tag interface as follows. Compile it and place it
under the web-inf/classes directory (in the appropriate package structure).
Tag Library Descriptor (TLD) file : Now we need to describe the tag, so create a file called "taglib.tld" and place it under the web-inf directory.
JSP file :
Deployment of application (OUTPUT) :
Ask your questions, our development team will try to give answers to your questions.