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

Introduction To Jsp Standard Template Library (jstl)

By Author: Infocampus
Total Articles: 182

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

Computer Programming Articles

1. Web Application Development – How To Choose Technology
Author: Siyaram Ray

2. Functional Automation Testing - Advantages Of Using Selenium In It
Author: Siyaram Ray

3. Php Development Company In Bhubaneswar
Author: xprosolutions

4. Digital Products Selling Clickbank Website Chandigarh
Author: Bhuvnesh Aggarwal

5. Introduction Of Web Development For Beginners
Author: Siyaram Ray

6. 7 Up Coming Website Architecture Patterns Form Infocampus
Author: Infocampus Logics Pvt Ltd

7. 5 Ways To Choose The Right App Development Company
Author: Vincent Bryan

8. How To Connect A Wired And Wireless Both Printer
Author: sara williams

9. Importance Of Angularjs For Next Project
Author: Siyaram Ray

10. How To Fix Aol Error 101?
Author: sara williams

11. Official Toshiba Support | Toshiba
Author: Toshiba Backup

12. Application Development – Benefits Of Angularjs 2
Author: Siyaram Ray

13. Decoding The Importance Of Jewellery Software For Businesses
Author: Danish Mehta

14. How To Hire The Best Magneto Developer At An Affordable Price
Author: Anderson Mairay

15. In Detail About Angular And Angular2
Author: Siyaram Ray

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