Java Standard Tag Library - Designing and developing web applications

Java Standard Tag Library

Sun continued to develop JSP technology as a development platform, including the possibility of creating its own JSP tags. As a result, a large number of specialized gags developed locally by different groups of developers appeared, which led to even greater confusion. Initially, Sun did not provide any standards or guidelines for organizing and structuring custom tags.

However, the company then proposed a Java standard tag library (JSTL) specification for the Java standard tag library. It included standards for iteration tags, conditional processing, database access, and many other tags that allow formatting. JSTL was originally created as an optional addition to JSP, but later it and its associated expression languages ​​were included in the JSP 2.0 specification.

JSTL tags are divided into several categories:

• basic tags that provide standard functionality that is common for the template approach: including, iterating, checking conditions, and so on;

• XML tags that provide similar functionality in an XML context, as well as the ability to traverse XML document elements using XPath expressions;

• SQL tags that provide tools for describing data sources, providing queries and performing iterations based on retrieved results from a database;

• formatting tags that include internationalization and localization functions, as well as tools for formatting dates and numbers.

In Fig. 3.10 shows the use of JSTL-tags to perform a query to a database and the presentation of the results as an HTML table. JSTL-tag is used to perform a cycle on rows received from the database and execute them in an HTML table (HTML tags ) with individual column values ​​represented by JSP Expression Language as HTML table cells (HTML -gags & lt; td & gt;).

The SQL tags at the beginning of the template (& lt; sql: setDataSource & gt; and & lt; sql: query & gt;) connect to the database, return the results and assign them to variables. Base tag & lt; c: forEach & gt; executes a cycle based on the results of querying the database, shows each resulting row (record) as an HTML table row (& lt; tr & gt;) in which each cell (& lt; td & gt;) contains a value for each result column an example for the Cold Fusion technology in Figure 3.6).

JSP page using JSTL technology and the result

Fig. 3.10. JSP page using JSTL technology and the result

Parameter substitution is performed using the expression language (EL), which is associated with JSTL, which provides access to variables defined in different areas: on the page (rade), in the query, session of the user (session) or the entire application in whole (application). The variables are accessed as follows: $ {scopeName.variableName}, where scopeName is the scope of the variable definition (page, session or application). This invocation of variables is further extended by using complex Java objects, including arrays, collections, and maps (for example, $ {session.myObject.myMemberVariable}).

JSTL made it possible to compile JSP pages without including Java code in it. Thus, this technology provided useful possibilities for the implementation of the View component in JSP Model 2, especially in such an object MVC environment as Struts. Although JSTL has all the capabilities to create full-fledged web applications, it is mainly used as a technology for developing Views in the context of MVC object environments.

thematic pictures

Also We Can Offer!

Other services that we offer

If you don’t see the necessary subject, paper type, or topic in our list of available services and examples, don’t worry! We have a number of other academic disciplines to suit the needs of anyone who visits this website looking for help.

How to ...

We made your life easier with putting together a big number of articles and guidelines on how to plan and write different types of assignments (Essay, Research Paper, Dissertation etc)