Javaserver Pages





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
JSP Tutorial
Introduction Introduction
Installing JDK-Windows Installing JDK-Windows
Installing JDK-Linux Installing JDK-Linux
Installing Tomcat Installing Tomcat
Simple Program in JSP Simple Program in JSP
Pre-defined Variables Pre-defined Variables
Syntax of Tags Syntax of Tags
JSP Expression Language JSP Expression Language
JSP EL Operators JSP EL Operators
EL Implicit Variables EL Implicit Variables
Scopes Scopes
Using Arrays Using Arrays
Methods Methods
JSP Elements JSP Elements
Including Beans Including Beans
JSTL Tags JSTL Tags
Custom Tags Custom Tags
Session Session in JSP
Handling Cookies Handling Cookies
JSP Application Structure JSP Application Structure
Configuring web.xml Configuring web.xml
Tomcat Configuration Tomcat Configuration
JSP Examples JSP Examples
Forums Ask Your Doubts
Feedback Feedback
 

JSP Standard Tag Library of JSP


Tutorials Jsp

Topic

How is JSP Standard Tag Library used in JSP?



Explanation

JSP Standard Tag Library (JSTL) was introduced to ease the programming in JSP by storing generic tasks in tag libraries under four different categories based on conditional processing and looping, XML processing, Internationalization and formatting, database access and a set of expression language functions.

Syntax:
   <%@ taglib uri="URIToTagLibrary" prefix="tagPrefix" %>

In the above example the "uri" points to the tag library "matlib.tld", the prefix used in the taglib directive as well as in the coding is same that is "mtaglib".

The following table lists the URI for the JSTL 1.1 libraries.

Library URI Prefix
Core http://java.sun.com/jsp/jstl/core c
XML Processing http://java.sun.com/jsp/jstl/xml x
l18N formatting http://java.sun.com/jsp/jstl/fmt fmt
Database access http://java.sun.com/jsp/jstl/sql sql
Functions http://java.sun.com/jsp/jstl/functions fn
Example:
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" 
    prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" 
    prefix="fn" %>
    <html>
    <head><title>JSTL Functions</title></head>
    <form>
    USERNAME:<input type="text" name="usr" size="25">
    <p></p>
    <input type="submit" value="Submit">
    <input type="reset" value="Reset">
    </form>
    <br>
    Length of your Username is::
    <c:out value="${fn:length(param.usr)}" />

In the above example first taglib directive points to the JSTL core tag library with prefix "c". So the "<c:out" statement works fine. For the functions like "${fn:length(param.usr)}" that can be invoked using the JSP Expression Language we include the JSTL function library with prefix "fn". The above example outputs the length of the username entered.






A Note
JSP(Java Server Pages) is one of the most used Server Side Programming Language in the world. Simple introduction, basic program codes with examples. Begin coding your own JSP scripts with this online tutorial. Hope you enjoy this tutorial. Do send your feedback or suggestions on this JavaServer Pages tutorial. This is a copyright content.


Other Links

web hosting