123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computer-Programming >> View Article

Introduction To Jsp Standard Template Library (jstl)

By Author: Infocampus
Total Articles: 281

JSTL was introduced was to allow JSP programmers to program using tags rather than Java code. To show why this is preferable, a quick example is in order. We will examine a very simple JSP page that counts to ten. We will examine this page both as regular scriptlet-based JSP, and then as JSTL.
Installing JSTL
To use JSTL, you must have a JSP 1.2 (or higher) container installed. One of the most commonly used JSP containers is the Apache Tomcat Web server. You can obtain a copy of Tomcat from http://jakarta.apache.org/tomcat/. Using Tomcat alone will allow you to use regular JSP scriptlet code. To use JSTL, you must install JSTL into Tomcat. JSTL can be obtained from the same source as Tomcat. The main URL for JSTL is http://java.sun.com/products/jsp/jstl/. To use JSTL, you must unzip the distribution files and install them into the correct locations within Tomcat.
To properly install JSTL for use with Tomcat, follow these three steps:

1. Copy the JSTL JAR files to Tomcat's lib directory.

If you are using Windows, the likely location of your lib directory is C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\lib. There are a number of JAR files included with the JSTL release. You should copy each of these JAR files to the Tomcat JAR directory.

2. Copy the JSTL TLD files to Tomcat's web-inf directory.

The web-inf directory is likely at this location: C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF. If you examine the JSTL distribution files, you should notice eight files that end with the TLD extension. All eight files should be copied to your web-inf directory.

3. Modify the web.xml file to include the TLD files.

Finally, you must modify your web.xml, and add an entry for all eight of the tag libraries that you added.
The JSTL Tag Libraries
JSTL is often spoken of as a single-tag library. JSTL is actually four tag libraries. These tag libraries are summarized as follows.
• Core Tag Library—Contains tags that are essential to nearly any Web application. Examples of core tag libraries include looping, expression evaluation, and basic input and output.

• Formatting/Internationalization Tag Library—Contains tags that are used to and parse data. Some of these tags will parse data, such as dates, differently based on the current locale.

• Database Tag Library—Contains tags that can be used to access SQL databases. These tags are normally used only to create prototype programs. This is because most programs will not handle database access directly from JSP pages. Database access should be embedded in EJBs that are accessed by the JSP pages.

• XML Tag Library—Contains tags that can be used to access XML elements. Because XML is used in many Web applications, XML processing is an important feature of JSTL.
In this article, we will only take a brief look at a few of the core tags. We will examine a simple example that shows how to process data that a user enters into a form. Before we examine this program, we must first see how JSTL handles expressions. Expression handling in JSTL is accomplished by using the EL expression language, just as it is done in JSP 2.0. In the next section, we will examine the EL expression language.
This article showed you some of the differences between the JSTL and standard JSP scriptlet programming. As you can see, JSTL allows a more consistent programming environment by allowing both HTML and procedural code to be expressed as tags. JSTL and tag libraries represent a new method of programming Web pages.
JSTL does not provide everything that a programmer would need to create a full-featured Web application. Further, some procedures that could be programmed in JSTL is often best not programmed in JSTL. One perfect example of this is the database JSTL tags. Except for very small Web applications, it is generally considered bad programming practice to embed actual database commands into a JSP page. The proper location for such program code is in Java beans and EJBs that will be used by your Web application. For such routines, you may consider creating your own tag libraries. This way, your JSP pages can use JSTL to perform basic programming procedures that are not unique to your business. You should implement your own tag libraries to implement components, which are unique to your business, which will be used by your Web application.
JSTL allows you to create a very consistent programming JSP-based application. This is done not just through JSTL, but through a combination of JSTL, your own custom tag libraries, and an underlying database. Understanding each of these components allows you to deploy an effective Web application.

Total Views: 39Word Count: 751See All articles From Author

Computer Programming Articles

1. Explain The New Features In Java 7
Author: Individual

2. Why Should You Learn Selenium Ide For Test Automation
Author: Siyaram Ray

3. What Is Builder Design Pattern In Java?
Author: Individual

4. Advantages To Having A Warehouse Management System
Author: brilliant info

5. Web Development Patterns Of 2018 And 2019
Author: Siyaram Ray

6. 5 Factors Why Java Professionals Should Know Hadoop.
Author: Individual

7. Brief Introduction Of Selenium Automation Framework
Author: Siyaram Ray

8. Seo Tip And Techniques 2018
Author: Ammy

9. Advantages Of Learning Web Development The Right Way
Author: Siyaram Ray

10. The Computer Repair Service Waukesha Is Your One Stop For All Hardware And Software Issues
Author: adronseton

11. All About The Phases Of Software Development Procedure
Author: Henry Smith

12. Java Vs Python: Which Programming Language To Master?
Author: Individual

13. 9 Myths Regarding Seo That You Simply Ought To Stop Basic Cognitive Process Nowadays
Author: emly

14. Selenium Testing – Common And Difficult Interview Questions
Author: Siyaram Ray

15. Concrete Scanning
Author: concrete scanning

Login To Account
Login Email:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: