9/1/10

Introduction to JSTL using NetBeans

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: 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, <>= 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. Sphere: Related Content

Developing Web Applications, Servlets and JSPs for WebLogic Server

Document Scope and Audience

This document is a resource for software developers who develop Web applications and components such as HTTP servlets and JavaServer Pages (JSPs) for deployment on WebLogic Server®. This document is also a resource for Web application users and deployers. It also contains information that is useful for business analysts and system architects who are evaluating WebLogic Server or considering the use of WebLogic Server Web applications for a particular application.

The topics in this document are relevant during the design and development phases of a software project. The document also includes topics that are useful in solving application problems that are discovered during test and pre-production phases of a project.

This document does not address production phase administration, monitoring, or performance tuning topics. For links to WebLogic Server documentation and resources for these topics, see Related Documentation.

It is assumed that the reader is familiar with J2EE and Web application concepts. This document emphasizes the value-added features provided by WebLogic Server Web applications and key information about how to use WebLogic Server features and facilities to get a Web application up and running.



Guide To This Document
■This chapter, Introduction and Roadmap, introduces the organization of this guide.
■Understanding Web Applications, Servlets, and JSPs, provides an overview of WebLogic Server Web applications, servlets, and Java Server Pages (JSPs).
■Creating and Configuring Web Applications, describes how to create and configure Web application resources.
■Creating and Configuring Servlets, describes how to create and configure servlets.
■Creating and Configuring JSPs, describes how to create and configure JSPs.
■Configuring JSF and JSTL Libraries, describes how to configure JavaServer Faces (JSF) and the JSP Tag Standard Library (JSTL).
■Configuring Resources in a Web Application, describes how to configure Web application resources.
■WebLogic Annotation for Web Components, describes how to simplify development by using annotations and resource injection with Web components.
■Servlet Programming Tasks, describes how to write HTTP servlets in a WebLogic Server environment.
■Using Sessions and Session Persistence, describes how to set up sessions and session persistence.
■Application Events and Event Listener Classes, discusses application events and event listener classes.
■Using the HTTP Publish-Subscribe Server, provides an overview of the HTTP Publish-Subscribe server and information on how you can use it in your Web applications
■WebLogic JSP Reference, provides reference information for writing JavaServer Pages (JSPs).
■Filters, provides information about using filters in a Web application.
■Using WebLogic JSP Form Validation Tags, describes how to use WebLogic JSP form validation tags.
■Using Custom WebLogic JSP Tags (cache, process, repeat), describes the use of three custom JSP tags—cache, repeat, and process—provided with the WebLogic Server distribution.
■Using the WebLogic EJB to JSP Integration Tool, describes how to use the WebLogic EJB-to-JSP integration tool to create JSP tag libraries that you can use to invoke EJBs in a JavaServer Page (JSP). This document assumes at least some familiarity with both EJB and JSP.
■web.xml Deployment Descriptor Elements, describes the deployment descriptor elements defined in the web.xml schema under the root element .
■weblogic.xml Deployment Descriptor Elements, provides a complete reference for the schema for the WebLogic Server-specific deployment descriptor weblogic.xml.
■Web Application Best Practices, contains Oracle best practices for designing, developing, and deploying WebLogic Web applications and application resources. Sphere: Related Content