JSTL Gives Web Applications Flexibility
While scripting languages like PHP continue to draw wide appeal, there are downsides. Try JSP tag libraries for a faster approach
by Alan Berg
February 14, 2006
Scripting languages are quick to develop and easy to manipulate. If you want to build a dynamic Web site in a day or make quick changes to CGI-like scripts, then with relatively few learning hours you can apply scripting languages to these tasks. Further, with scripting languages like PHP, a server-side scripting language that is vaguely similar to C, you gain the potential for rapid development cycles. Once you enact a change, the change propagates live.
These are excellent characteristics of PHP, and what's even better is the language has the reputation of running fast. However, on the dark side there are some drawbacks. Without rigid control, code grows unruly and may become costly to maintain and hard to debug. The diffusion of logic and HTML presentation tags can make for pronounced readability issues. The same issue is true for JSP coding. Struts and other high-level Java frameworks that use the Model-View-Controller (MVC) pattern combat the maintenance issues by dividing applications in such a way that Web designers are not bothered with Java coding. Further, Java coders avoid the majority of the interaction design and graphical user interface (GUI) coding.
However, this separation of tasks between the GUI designer and programmer also has a price; the frameworks have a significant learning curve and indirectly expect a team-like infrastructure that is commonly only found in mid-size to large projects. For small companies the learning curve associated with the frameworks sometimes represents an unrealistic barrier. We may need to be better at addressing the needs of the small businesses and small office/home offices (SOHOs). One possibility for rapid application cycles and instant code changes is pure JavaServer Page (JSP) coding, including all the potential readability and growth pains the practice may entail.
Easier Web Apps
The JavaServer Standard Tag Library (JSTL) is a superset of JSP that attempts to encapsulate commonly required functionality within a series of four extra tag libraries. The idea behind it is to allow for easier creation of Web applications without resorting to mixing Java code in with tags so quickly. Common Web application functionality is encapsulated. JSP has an expression language (EL) that allows for easier plumbing to sessions and beans. For example, the expression:
${sessionScope.driver}
obtains the value of the attribute driver from the scope session. Without EL some of the basic JSP coding is verbose. For example, obtaining a property from a bean in EL is similar to ${login.UID}, where as without EL the resulting code is:
<%= ((Login) pageContext.
getAttribute("login")).getUID
() %>
Note that EL is supported by JSTL but can function outside the extra tag libraries as well. The four logically divided JSTL tag libraries are: core, which works with basic programming constructs such as iterations; internationalization and formatting, which allows for the loading and use of resource bundles for internationalization and the general manipulation of string formatting; SQL, which enables connection to databases through data sources as well as the general manipulation of databases; and XML, which is used for generic manipulations. Note here that with up-and-coming technologies such as AJAX that make extensive use of XML, expect to see more use of the XML library.
Back to top
|