Java Sevelets Tutorial

Topics: XML, JavaServer Pages, Exception handling Pages: 31 (11567 words) Published: April 27, 2012
JSP Standard Tag Library (JSTL) Tutorial
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: 1. Core Tags

2. Formatting tags
3. SQL tags
4. XML tags
5. JSTL Functions
Install JSTL Library:
If you are using Apache Tomcat container then follow the following two simple steps: 1. Download the binary distribution from Apache Standard Taglib and unpack the compressed file. 2. To use the Standard Taglib from its Jakarta Taglibs distribution, simply copy the JAR files in the distribution's 'lib' directory to your application's webapps\ROOT\WEB-INF\lib directory. To use any of the libraries, you must include a <taglib> directive at the top of each JSP that uses the library. Core Tags:

The core group of tags are the most frequently used JSTL tags. Following is the syntax to include JSTL Core library in your JSP: <%@ taglib prefix="c" uri="" %>| There are following Core JSTL Tags:

Tag| Description|
<c:out >| Like <%= ... >, but for expressions.| <c:set >| Sets the result of an expression evaluation in a 'scope'| <c:remove >| Removes a scoped variable (from a particular scope, if specified).| <c:catch>| Catches any Throwable that occurs in its body and optionally exposes it.| <c:if>| Simple conditional tag which evalutes its body if the supplied condition is true.| <c:choose>| Simple conditional tag that establishes a context for mutually exclusive conditional operations, marked by <when> and <otherwise>| <c:when>| Subtag of <choose> that includes its body if its condition evalutes to 'true'.| <c:otherwise >| Subtag of <choose> that follows <when> tags and runs only if all of the prior conditions evaluated to 'false'.| <c:import>| Retrieves an absolute or relative URL and exposes its contents to either the page, a String in 'var', or a Reader in 'varReader'.| <c:forEach >| The basic iteration tag, accepting many different collection types and supporting subsetting and other functionality .| <c:forTokens>| Iterates over tokens, separated by the supplied delimeters.| <c:param>| Adds a parameter to a containing 'import' tag's URL.| <c:redirect >| Redirects to a new URL.|

<c:url>| Creates a URL with optional query parameters| Formatting tags:
The JSTL formatting tags are used to format and display text, the date, the time, and numbers for internationalized Web sites. Following is the syntax to include Formatting library in your JSP: <%@ taglib prefix="fmt" uri="" %>| Following is the list of Formatting JSTL Tags:

Tag| Description|
<fmt:formatNumber>| To render numerical value with specific precision or format.| <fmt:parseNumber>| Parses the string representation of a number, currency, or percentage.| <fmt:formatDate>| Formats a date and/or time using the supplied styles and pattern| <fmt:parseDate>| Parses the string representation of a date and/or time| <fmt:bundle>| Loads a resource bundle to be used by its tag body.| <fmt:setLocale>| Stores the given locale in the locale configuration variable.| <fmt:setBundle>| Loads a resource bundle and stores it in the named scoped variable or the bundle configuration variable.|...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Java Essay
  • Essay on Java
  • Java Essay
  • Java Research Paper
  • java Essay
  • JAVA Essay
  • java Essay
  • Java Essay

Become a StudyMode Member

Sign Up - It's Free