Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a taglib?

Tags:

java

taglib

Can someone explain what a taglib is in respect to Java programming? It contains a prefix and uri...but what do each of these refer to? I looked up a number of different websites but am frankly am still confused about what it is and what it does.

like image 528
Daron Avatar asked Dec 03 '14 18:12

Daron


People also ask

What is prefix in taglib?

The prefix attribute defines the prefix that distinguishes tags defined by a given tag library from those provided by other tag libraries. If the tag library is defined with tag files (see Encapsulating Reusable Content Using Tag Files), you supply the tagdir attribute to identify the location of the files.

Is taglib a directive?

The taglib Directive Specify a shortcut URI, as defined in a web. xml file (see "Use of web. xml for Tag Libraries" above). Fully specify the tag library description (TLD) file name and location.

Can we use taglib in HTML?

This taglib contains tags used to create struts input forms, as well as other tags generally useful in the creation of HTML-based user interfaces.

What is JSP taglib at least 5?

The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates the core functionality common to many JSP applications. JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags.


2 Answers

The JavaServer Pages API allows you to define custom JSP tags that look like HTML or XML tags and a tag library is a set of user-defined tags that implement custom behavior.

The taglib directive declares that your JSP page uses a set of custom tags, identifies the location of the library, and provides a means for identifying the custom tags in your JSP page.

Original source: JSP - The taglib Directive

like image 98
K.Nicholas Avatar answered Sep 28 '22 03:09

K.Nicholas


The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications.

JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags. It also provides a framework for integrating existing custom tags with JSTL tags.

The JSTL tags can be classified, according to their functions, into following JSTL tag library groups that can be used when creating a JSP page:

Core Tags

Formatting tags

SQL tags

XML tags

JSTL Functions

Each group of tags has the following core structure:

<%@ taglib prefix="some prefix" 
           uri="some http URL" %>

More info you can find here.

like image 28
Yegor Korotetskiy Avatar answered Sep 28 '22 04:09

Yegor Korotetskiy