The JavaTM Web Services Tutorial
Home
TOC
PREV TOP NEXT

What Is a JSP Page?

A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format, such as HTML, SVG, WML, and XML; and JSP elements, which construct dynamic content. A syntax card and reference for the JSP elements are available at

http://java.sun.com/products/jsp/technical.html#syntax
 

The Web page in Figure 14-1 is a form that allows you to select a locale and displays the date in a manner appropriate to the locale.

Figure 14-1 Localized Date Form

The source code for this example is in the docs/tutorial/examples/web/date directory created when you unzip the tutorial bundle. The JSP page index.jsp used to create the form appears below; it is a typical mixture of static HTML markup and JSP elements. If you have developed Web pages, you are probably familiar with the HTML document structure statements (<head>, <body>, and so on) and the HTML statements that create a form <form> and a menu <select>. The lines in bold in the example code contains the following types of JSP constructs:

To build, deploy, and execute this JSP page:

  1. In a terminal window, go to docs/tutorial/examples/web/date.
  2. Run ant build. The build target will spawn any necessary compilations and copy files to the docs/tutorial/examples/web/date/build directory.
  3. Run ant install. The install target notifies Tomcat that the new context is available.
  4. Open the date URL http://localhost:8080/date.

You will see a combo box whose entries are locales. Select a locale and click Get Date. You will see the date expressed in a manner appropriate for that locale.

Home
TOC
PREV TOP NEXT