2. Using the Tutorial Examples 3. Getting Started with Web Applications 5. JavaServer Pages Technology Using Objects within JSP Pages Using Application-Specific Objects Immediate and Deferred Evaluation Syntax Deactivating Expression Evaluation Process of Expression Evaluation JavaBeans Component Design Conventions Creating and Using a JavaBeans Component Setting JavaBeans Component Properties Retrieving JavaBeans Component Properties Including the Tag Library Implementation Transferring Control to Another Web Component Setting Properties for Groups of JSP Pages Deactivating EL Expression Evaluation Further Information about JavaServer Pages Technology 7. JavaServer Pages Standard Tag Library 10. JavaServer Faces Technology 11. Using JavaServer Faces Technology in JSP Pages 12. Developing with JavaServer Faces Technology 13. Creating Custom UI Components 14. Configuring JavaServer Faces Applications 15. Internationalizing and Localizing Web Applications 16. Building Web Services with JAX-WS 17. Binding between XML Schema and Java Classes 19. SOAP with Attachments API for Java 21. Getting Started with Enterprise Beans 23. A Message-Driven Bean Example 24. Introduction to the Java Persistence API 25. Persistence in the Web Tier 26. Persistence in the EJB Tier 27. The Java Persistence Query Language 28. Introduction to Security in the Java EE Platform 29. Securing Java EE Applications 31. The Java Message Service API 32. Java EE Examples Using the JMS API 36. The Coffee Break Application | What Is a JSP Page?AJSP page is a text document that contains two types of text: staticdata, which can be expressed in any text-based format (such asHTML,SVG,WML, andXML), and JSP elements, which construct dynamic content. The recommended file extension for the source file of a JSP pageis.jsp. The page can be composed of a top file thatincludes other files that contain either a complete JSP page or a fragmentof a JSP page. The recommended extension for the source file of afragment of a JSP page is.jspf. The JSP elements in a JSP page can be expressed in twosyntaxes, standard and XML, though any given file can use only one syntax.A JSP page in XML syntax is an XML document and can bemanipulated by tools and APIs for XML documents. This chapter and ChaptersChapter 7, JavaServer Pages Standard Tag LibrarythroughChapter 9, Scripting in JSP Pages document only the standard syntax. The XML syntax is covered inChapter 6, JavaServer Pages Documents. A Simple JSP Page ExampleThe web page inFigure 5-1 is a form that allows you to selecta locale and displays the date in a manner appropriate to the locale. Figure 5-1 Localized Date Form ![]() The source code for this example is in thetut-install/javaeetutorial5/examples/web/date/ directory. TheJSP page,index.jsp, appears below; it is a typical mixture of static HTMLmarkup and JSP elements. If you have developed web pages, you are probablyfamiliar with the HTML document structure statements (<head>,<body>, and so on) and theHTML statements that create a form (<form>) and a menu (<select>). The lines in bold in the example code contain the following typesof JSP constructs:
Here is the JSP page: <%@page contentType="text/html; charset=UTF-8" %><%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><%@taglib uri="/functions" prefix="f" %><html><head><title>Localized Dates</title></head><body bgcolor="white"><jsp:useBean scope="application" /><form name="localeForm" action="index.jsp" method="post"><c:set var="selectedLocaleString" value="${param.locale}" /><c:set var="selectedFlag" value="${!empty selectedLocaleString}" /><b>Locale:</b><select name=locale><c:forEach var="localeString" items="${locales.localeNames}" ><c:choose> <c:when test="${selectedFlag}"> <c:choose> <c:when test="${f:equals(selectedLocaleString, localeString)}" > <option selected>${localeString}</option> </c:when> <c:otherwise> <option>${localeString}</option> </c:otherwise> </c:choose> </c:when> <c:otherwise> <option>${localeString}</option> </c:otherwise></c:choose></c:forEach></select><input type="submit" name="Submit" value="Get Date"></form><c:if test="${selectedFlag}" > <jsp:setProperty name="locales" property="selectedLocaleString" value="${selectedLocaleString}" /> <jsp:useBean/> <jsp:setProperty name="date" property="locale" value="${locales.selectedLocale}"/> <b>Date: </b>${date.date}</c:if></body></html> To deploy thedate application with NetBeans IDE, follow these steps:
To deploy thedate application with the Ant tool, follow these steps:
To run the example, do the following:
Some of the characters might not display properly if you don’t have theappropriate language files installed on your machine. Consult the user guide or onlinehelp for your operating system to determine how you can install these languagefiles. Copyright © 2010, Oracle and/or its affiliates. All rights reserved.Legal Notices |