123ArticleOnline Logo
Welcome to 123ArticleOnline.com!

ALL >> Computer-Programming >> View Article

Introduction To Jsp Standard Template Library (jstl)

By Author: Infocampus
Total Articles: 100

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.
Conclusions
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: 7Word Count: 751See All articles From Author

Computer Programming Articles

1. Selenium Testing Strategy – Automation Testing Tool
Author: Siyaram Ray

2. Open Source Tools For Java Deployment
Author: Infocampus

3. Single Versus Multi-tenant Saas – Which Is Best?
Author: namitaghate

4. A Popular Automation Testing Tool - Selenium
Author: Siyaram Ray

5. Disc Publishing Media - Time For Entertainment Anytime And Anywhere
Author: Lingan

6. Step By Step Guidelines To Succeed With Selenium - Automation Testing Tool
Author: Siyaram Ray

7. Automation Testing Tool - Selenium Architecture With Webdriver Features
Author: Siyaram Ray

8. Top 6 Patterns You Will See In 2018 Website Architecture
Author: Infocampus Logics Pvt Ltd

9. Ms Access Database Images: How To Correctly Handle Them ?
Author: Ben Beitler

10. How Android App Development Are Beneficial For Business
Author: Meer Sayed

11. Know Why Selenium Is Popular And Features Of Selenium Webdriver
Author: Siyaram Ray

12. 8 Great Applications Of “machine Learning”
Author: Sana Mulla

13. How To Learn Machine Learning From Scratch?
Author: Sana Mulla

14. Machine Learning “hello World” Using Python
Author: Sana Mulla

15. Logistics App Development: The Tech Behind
Author: Recrosoft Technologies

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