Developing Web applications with JSP 2.0

Source: Internet
Author: User
Tags new features tomcat

The JSP (JavaServer Pages) technology is a further abstraction of the servlet, developed by JCP (Java Community Process), is an open, freely accessible specification for generating dynamic content, and is also Java 2 Enterprise Edition) is an important part of the specification. Many business application servers such as Bea WebLogic, IBM WebSphere, Live JRun, and Orion support JSP technology.

JSP technology is applied everywhere on the web, from ticket reservation systems to banking systems to shopping systems. The new release of version 2.0 is an upgrade to JSP1.2, adding some interesting new features. The goal of JSP2 is to make the design of dynamic Web pages easier and without learning the Java programming language.

The content of this article includes:

Provide a tutorial with rich sample code to familiarize you with JSP2.0

Introducing new features of JSP2.0

Some of the experience with JSP2.0 development applications gives some sample code that can be slightly modified for your own application.

If you are not familiar with JSP, it is a good idea to start directly from JSP2.0. But if you want to learn JSP1.2, maybe you need to start learning from the JSP tutorial.

JSP 2.0

JSP 2.0 is an upgrade to JSP 1.2, adding several interesting new features that make it easier for Web application designers and developers to work. The goal of JSP 2.0 is to be easier to use than it used to be, and, more importantly, to use it without learning the Java language itself. It adds a new extension mechanism called Simpletag to simplify the tagging API (Tag API).

Among other improvements, the most important new features introduced by JSP 2.0 include:

A simple expression language (EL) that can be used to easily access data from JSP pages, which simplifies the authoring of JSP-free applications without the need to use Java scriptlet or Java expressions;

A new syntax for directly using JSP technology to define reusable custom behavior that uses. tag and. tagx files, which can be written by developers or web page authors;

The 3XML syntax has been substantially improved by adding a new standard file name extension (. tagx for tag files,. jspx for JSP files).

This article mainly discusses the expression language, the simplified label API, and the label file. It is believed that the current JSP developers will find these important features interesting and useful. Why do we have to jump from 1.2 to 2.0?

The version number in the Java Specification request (JSR 152) is initially set to 1.3. But as you'll see later, because these new features have such a profound impact on the development model of the JSP application, the group feels the need to upgrade the major version number to 2.0 in order to fully reflect the impact. In addition, the new version number helps to draw developers ' attention to these interesting new features. Thankfully, all legitimate JSP1.2 pages are also legitimate JSP2.0 pages.

JSP 2.0 Start

Before you start learning JSP 2.0, you need a JSP environment that supports the JSP2.0 and Java Servlet 2.4 specification. Fortunately, the Jakarta Tomcat 5.0 (Alpha Beta) supports the new JSP2.0 and servlet 2.4 specification, which can be from http://jakarta.apache.org/builds/jakarta-tomcat/ release/v5.0.4-alpha/Download and install Tomcat 5.0.

JSP expression language

Passing information to a JSP Web page is done through the JSP scoped properties and request parameters. An expression language (EL) tailored specifically for Web authors promotes the JSP scoped attribute as a standard way of delivering information from business logic to JSP pages. However, note that although this expression language is an important feature of JSP, it is not a common programming language. It is simply a data access language that makes it easy to access and process application data without the use of scriptlet or the value of a request-time (request-time) expression.

Before JSP2.0, Web page authors can only use the expression <%= aname%> access the value of the system, such as the following example:

<someTags:aTag attribute="<%= pageContext.getAttribute("aName") %>">

Or use the value of the custom JavaBeans component:

<%= aCustomer.getAddress().getCountry() %>

An expression language allows Web page authors to access objects using simple syntax. For example, to access a simple variable, you can write as follows:

<someTags:aTag attribute="${ aName}">

To access nested JavaBeans properties, you can write as follows:

${ aCustomer.address.country}

You might ask, is this not JavaScript syntax? Absolutely right! If you've ever used JavaScript, you'll feel very relaxed because the expression language borrows the JavaScript syntax to access structured data.

--------------------------------------------------------------------------------

Attention:

The expression language was originally developed as part of the JSP Standard Tag Library (JSTL) 1.0, and JSTL is a standard tag library that provides support for common, structured tasks such as iterations and conditions, XML document processing, internationalization, and access to databases using SQL. The JSTL specification was developed by the JSR 52 expert group. For an introduction to JSTL, see faster Development with JSTL (Accelerated development with JSTL).

--------------------------------------------------------------------------------

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.