java left logo
java middle logo
java right logo
 

Home arrow Java Tutorials arrow Introduction to JSTL using NetBeans
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4096
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
Introduction to JSTL using NetBeans E-mail
User Rating: / 163
PoorBest 

Introduction

The latest version of JSTL is JSTL 1.1. Without any hesitation, JSTL is now extremely important in ensuring the success of the J2EE web application projects. JSTL is basically part of JSP 2.0 specification and requires Java Servlet 2.4 and higher to support its tags.

After completing this tutorial, you are expected to be able to apply JSTL technology to your JSP, know what are JSTL tags, know how and when to use certain tags under certain circumstances according to your needs.

Specifics Information on JSTL and Netbeans

This tutorial has been compiled, tested and run under:

  1. Netbeans 5.5
  2. JSTL 1.1 library package
  3. Tomcat 5.5.7 as server

If you have installed NetBeans successfully, JSTL library (.jar) can be found on your local hard disk. It is bundled together with Netbeans. For your information, it can be found in: netbeans_installation_folder\enterprise1\config\TagLibraries\JSTL11

You can also download JSTL taglib library from Jakarta apache project online website on http://jakarta.apache.org/builds/jakarta-taglibs/releases/standard/binaries/. Some included jar for JSTL 1.1 library are jaxen-full.jar, jstl.jar, saxpath.jar, standard.jar, xalan.jar. However, only jstl.jar and standard.jar are required. So why do we need those other jar files? Well, standard.jar depends on other jars like xalan.jar, saxpath.jar, dom.jar, etc to work properly. You can use J2SE 1.4.2 and higher to avoid these dependencies. However, as the JSTL taglib library has been bundled together with the NetBeans, you do not need to download it anymore.

Roadmap

  1. What is JSTL?
  2. Why use JSTL?
  3. Implementation of JSTL Core Tags
  4. Implementation of JSTL Formatting Tags
  5. Implementation of JSTL Function Tags
  6. Conclusion
  7. Appendix

 

1. What is JSTL?

JSTL stands for JSP Standard Tag Library. JSTL has been standardized and is being one of the most important technologies in implementing J2EE Web Application. The main objective of the JSTL is basically to simplify the Java codes within JSP (scriptlets) as well as to increase the level of reusability within our J2EE web application. Before JSTL is introduced, J2EE Web Applications (especially in the presentation layer – JSP) are extremely complex and are very tough to be maintained. It is true that the new developer may take some time to understand all the underlying codes within J2EE Web Application This is where JSTL should help.

Here is a simple JSTL flow concept; JSTL is compiled into a servlets (Java codes) before being displayed to JSP. Some classes of standard.jar are required to parse and translate these JSTL tags into servlets (Java codes). Lastly but not least, the servlet that has been compiled will be executed accordingly.

There are many more advantages of using JSTL compared to scriptlets. Therefore, it is recommended to replace scriptlets with JSTL in the presentation layer (JSP).

There are 5 major types of JSTL tags:

  1. JSTL Core tags, prefixed with c
  2. JSTL Format tags, prefixed with fmt
  3. JSTL Function tags, prefixed with fn
  4. JSTL Database tags, prefixed with sql
  5. JSTL XML tags, prefixed with x

 

JSTL Core Tags

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

Mainly used for replacement of scriptlet logical tags as well as basic URL handling tag such as catch, choose, if, forEach, param, when, redirect, import, url, etc.

 

JSTL Format Tags

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

Mainly used for displaying number and date time format. This could be used for internationalization support as well. Tags examples are setLocale, setTimeZone, setBundle, formatNumber, formatDate, etc.

 

JSTL Function Tags

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

Very useful JSTL tags. Most are used in conjunction with JSTL core tags. These tags are designed for manipulating string.

 

JSTL Database Tags

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>

Tags are used to interact with database level. With database tags you could do transaction, update and query the database from your UI level. Personally, I do not prefer these tags. The MVC design pattern should always be retained.

 

JSTL XML tags

<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>

Similar to core tags, except xml tags will deal with xml stuffs like parsing xml documents, validating xml documents, output an xpath and etc.

For depth details to all JSTL tags, you can find more information within your NetBean’s installation folder i.e. installation_netbeans_folder\enterprise1\docs\

Additionally, JSTL accepts the conditional operators like ‘eq’, ‘ne’, ’==’, ’null’, ’empty’, ’not’, ’!=’, ’>=’, ’<=’, ’and’, ’&&’, ’or’, ’||’ all are valid.

Here is the mapping of relational and logical operators with JSP Notations.

Operators

JSP Notation

>

gt

<

Lt

>=

ge

<=

le

==

eq

!=

ne

&&

and

||

or

!

not

‘’

empty

/

div

%

mod

While other arithmetic operators such as +, -, and * can also be used together with the JSTL tag as well.



 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.