Java Server Pages

Book description

JavaServer Pages (JSP) technology provides an easy way to create dynamic web pages. JSP uses a component-based approach that allows web developers to easily combine static HTML for look-and-feel with Java components for dynamic features. The simplicity of this component-based model, combined with the cross-platform power of Java, allows a web development environment with enormous potential. JavaServer Pages shows how to develop Java-based web applications without having to be a hardcore programmer. The author provides an overview of JSP concepts and discusses how JSP fits into the larger picture of web applications. Web page authors will benefit from the chapters on generating dynamic content, handling session information, accessing databases, authenticating users, and personalizing content. In the programming-oriented chapters, Java programmers learn how to create Java components and custom JSP tags for web authors to use in JSP pages.

Table of contents

  1. Java Server Pages
    1. Preface
      1. What’s in This Book
      2. Audience
        1. What You Need to Know
      3. Organization
        1. Part I, JSP Application Basics
        2. Part II, JSP Application Development
        3. Part III, JSP in J2EE and JSP Component Development
        4. Part IV, Appendixes
      4. About the Examples
      5. Conventions Used in This Book
      6. How to Contact Us
      7. Acknowledgments
    2. I. JSP Application Basics
      1. 1. Introducing JavaServer Pages
        1. What Is JavaServer Pages?
        2. Why Use JSP?
          1. Embedding Elements in HTML Pages
          2. Using the Right Person for Each Task
          3. Precompilation
          4. Integration with Enterprise Java APIs
          5. Other Solutions
            1. Active Server Pages (ASP)
            2. PHP
            3. ColdFusion
            4. Java servlet template engines
          6. The JSP Advantage
        3. What You Need to Get Started
      2. 2. HTTP and Servlet Basics
        1. The HTTP Request/Response Model
          1. Requests in Detail
          2. Responses in Detail
          3. Request Parameters
          4. Request Methods
          5. State Management
        2. Servlets
          1. Advantages Over Other Server-Side Technologies
          2. Servlet Life Cycle
          3. Servlet Containers
          4. Servlet Contexts
          5. Sessions
        3. Packaging Java Web Applications
      3. 3. JSP Overview
        1. The Problem with Servlets
        2. The Anatomy of a JSP Page
          1. JSP Elements
        3. JSP Processing
        4. JSP Application Design with MVC
      4. 4. Setting Up the JSP Environment
        1. Installing the Java Software Development Kit
        2. Installing the Tomcat Server
          1. Windows Platforms
          2. Unix Platforms
        3. Testing Tomcat
        4. Installing the Book Examples
        5. Example Web Application Overview
    3. II. JSP Application Development
      1. 5. Generating Dynamic Content
        1. What Time Is It?
          1. Using JSP Directives
          2. Using Template Text
          3. Using JavaBeans
          4. Accessing JavaBean Properties
        2. Input and Output
          1. Using JavaBeans to Process Input
            1. Setting JavaBeans properties from user input
            2. Validating user input
          2. Keep On Doing It ‘til You Get It Right
          3. Formatting HTML Output
      2. 6. Using Scripting Elements
        1. Java Primer
          1. Classes and Objects
            1. Data
            2. Methods
            3. Statements
            4. Inheritance
          2. Primitive Types
          3. Comments
          4. Standard Classes Commonly Used in JSP Pages
            1. String and StringBuffer
            2. Arrays
          5. Flow Control Statements
          6. Operators
        2. Implicit JSP Objects
        3. Conditional Processing
          1. Using JavaBeans Properties
          2. Using Request Information
          3. Working with Arrays
        4. Displaying Values
          1. Packages
          2. Checking Off Checkboxes Dynamically
          3. Using More Request Methods
        5. Using an Expression to Set an Attribute
        6. Declaring Variables and Methods
          1. jspInit( ) and jspDestroy( )
      3. 7. Error Handling and Debugging
        1. Dealing with Syntax Errors
          1. Element Syntax Errors
          2. Scripting Syntax Errors
        2. Debugging a JSP-Based Application
        3. Dealing with Runtime Errors
      4. 8. Sharing Data Between JSP Pages, Requests, and Users
        1. Passing Control and Data Between Pages
          1. Passing Control from One Page to Another
          2. Passing Data from One Page to Another
          3. All Together Now
        2. Sharing Session and Application Data
          1. Counting Page Hits
            1. Thread-safe beans
          2. URL Rewriting
        3. Using Custom Actions
        4. Online Shopping
          1. Number Formatting
          2. Using Request Parameters
          3. Redirect Versus Forward
        5. Memory Usage Considerations
      5. 9. Database Access
        1. Accessing a Database from a JSP Page
          1. Example Application Architecture
          2. Example Tables
          3. Reading and Storing Information in a Database
            1. JDBC drivers and the DataSource class
            2. Reading database information
            3. Inserting database information
            4. Updating database information
          4. Generating HTML from a Query Result
          5. Searching for Rows Based on Partial Information
          6. Deleting Database Information
        2. Input Validation Without a Bean
        3. Using Transactions
        4. Application-Specific Database Actions
      6. 10. Authentication and Personalization
        1. Container-Provided Authentication
          1. Authenticating Users
          2. Controlling Access to Web Resources
        2. Application-Controlled Authentication
          1. A Table for Personalization Information
          2. Logging In
            1. Using cookies to remember the username and password
          3. Authentication Using a Database
            1. Creating the validation object
            2. Setting and deleting cookies
            3. Redirect to the application page
          4. Checking for a Valid Session
            1. Providing personalized content
          5. Updating the User Profile
          6. Logging Out
        3. Other Security Concerns
      7. 11. Internationalization
        1. How Java Supports Internationalization and Localization
          1. The Locale Class
          2. Formatting Numbers and Dates
          3. Using Localized Text
        2. Generating Localized Output
          1. Using One Page for Multiple Locales
          2. Using a Separate Page for Each Locale
        3. A Brief History of Bits
        4. Handling Localized Input
          1. Dealing with Non-Western European Input
      8. 12. Bits and Pieces
        1. Buffering
        2. Including Page Fragments
        3. XML and JSP
          1. Generating an XML Document
          2. Transforming XML into HTML
          3. Transforming XML into a Request-Dependent Format
        4. Mixing Client-Side and Server-Side Code
          1. Generating JavaScript Code
          2. Using Java Applets
        5. Precompiling JSP Pages
        6. Preventing Caching of JSP Pages
        7. How URLs Are Interpreted
    4. III. JSP in J2EE and JSP Component Development
      1. 13. Web Application Models
        1. The Java 2 Enterprise Edition Model
        2. The MVC Model
          1. Using Only JSP
          2. Using Servlets and JSP
          3. Using Servlets, JSP, and EJB
        3. Scalability
          1. Preparing for Distributed Deployment
      2. 14. Combining Servlets and JSP
        1. Using a Servlet as the Controller
          1. Initializing Application Scope Objects
          2. Centralized Request Processing
          3. Mapping a URI Pattern to a Servlet
          4. Access Control for JSP Pages
        2. A More Modular Design Using Action Objects
        3. Sharing Data Between Servlets and JSP Pages
        4. Using a JSP Error Page for All Runtime Errors
      3. 15. Developing JavaBeans for JSP
        1. JavaBeans as JSP Components
          1. JavaBeans Naming Conventions
            1. Handling session events
        2. JSP Bean Examples
          1. Value Beans
          2. Utility Beans
          3. Multithreading Considerations
        3. Unexpected <jsp:setProperty> Behavior
      4. 16. Developing JSP Custom Actions
        1. Tag Extension Basics
        2. Developing a Simple Action
        3. Processing the Action Body
        4. Letting Actions Cooperate
        5. Creating New Variables Through Actions
        6. Developing an Iterating Action
        7. Creating the Tag Library Descriptor
        8. Validating Syntax
        9. How Tag Handlers May Be Reused
        10. Packaging and Installing a Tag Library
      5. 17. Developing Database Access Components
        1. Using Connections and Connection Pools
          1. Using a JDBC 2.0 Optional Package Connection Pool
          2. Making a JDBC 1.0 Connection Pool Behave as a JDBC 2.0 Connection Pool
          3. Making a Connection Pool Available to Application Components
        2. Using a Generic Database Bean
          1. The SQLCommandBean and Value Classes
          2. The Row and Column Classes
        3. Developing Generic Database Custom Actions
          1. The <ora:sqlQuery> and <ora:sqlUpdate> Actions
          2. The <ora:intValue> Action
          3. The <ora:sqlTransaction> Action
        4. Developing Application-Specific Database Components
    5. IV. Appendixes
      1. A. JSP Elements Syntax Reference
        1. Directive Elements
          1. include Directive
          2. page Directive
          3. taglib Directive
        2. Scripting Elements
          1. Declaration
          2. Expression
          3. Scriptlet
        3. Action Elements
          1. <jsp:fallback>
          2. <jsp:forward>
          3. <jsp:getProperty>
          4. <jsp:include>
          5. <jsp:param>
          6. <jsp:params>
          7. <jsp:plugin>
          8. <jsp:setProperty>
          9. <jsp:useBean>
          10. Custom Actions
        4. Comments
        5. Escape Characters
      2. B. JSP API Reference
        1. Implicit Variables
          1. application
          2. config
          3. exception
          4. out
          5. page
          6. pageContext
          7. request
          8. response
          9. session
        2. Servlet Classes Accessible Through Implicit Variables
          1. Cookie
          2. RequestDispatcher
        3. Tag Extension Classes
          1. BodyContent
          2. BodyTag
          3. BodyTagSupport
          4. Tag
          5. TagAttributeInfo
          6. TagData
          7. TagExtraInfo
          8. TagInfo
          9. TagLibraryInfo
          10. TagSupport
          11. VariableInfo
        4. Other JSP Classes
          1. HttpJspPage
          2. JspEngineInfo
          3. JspException
          4. JspFactory
          5. JspPage
          6. JspTagException
      3. C. Book Example Custom Actions and Classes Reference
        1. Generic Custom Actions
          1. <ora:addCookie>
          2. <ora:encodeHTML>
          3. <ora:encodeURL>
          4. <ora:getCookieValue>
          5. <ora:loop>
          6. <ora:menuItem>
          7. <ora:noCache>
          8. <ora:param>
          9. <ora:redirect>
          10. <ora:useProperty>
          11. <ora:validateSession>
        2. Internationalization Custom Actions
          1. <ora:getLocalDate>
          2. <ora:getLocalNumber>
          3. <ora:getLocalPageName>
          4. <ora:getLocalText>
          5. <ora:useLocaleBundle>
        3. Database Custom Actions
          1. <ora:sqlQuery>
          2. <ora:sqlTransaction>
          3. <ora:sqlUpdate>
          4. <ora:useDataSource>
          5. Value Action Elements
        4. Utility Classes
          1. ArraySupport
          2. CookieUtils
          3. DebugBean
          4. StringFormat
        5. Database Access Classes
          1. Reference Section
            1. ConnectionPool
          2. Reference Section
            1. ConnectionWrapper
          3. Reference Section
            1. DataSourceWrapper
          4. Reference Section
            1. Row
          5. Reference Section
            1. SQLCommandBean
          6. Value Classes
          7. Column Classes
      4. D. Web-Application Structure and Deployment Descriptor Reference
        1. Web Application File Structure
          1. Placing Java Class Files in the Right Directory
        2. Web Application Deployment Descriptor
          1. <icon>, <display-name>, and <description>
          2. <distributable>
          3. <context-param>
          4. <servlet>
          5. <servlet-mapping>
          6. <session-config>
          7. <mime-mapping>
          8. <welcome-file-list>
          9. <error-page>
          10. <taglib>
          11. <security-constraint>, <security-role>, and <login-config>
          12. <resource-ref >, <env-entry>, and <ejb-ref >
          13. Example Application Deployment Descriptor
        3. Creating a WAR File
      5. E. JSP Resource Reference
        1. JSP-Related Products
          1. Syntax-Aware Editors
          2. Web Page Authoring Tools
          3. Java IDEs with JSP support
          4. JSP Component Suites
          5. Web and Application Servers with JSP 1.1 Support
        2. Web Hosting
        3. Information and Specifications
    6. Index
    7. Colophon

Product information

  • Title: Java Server Pages
  • Author(s): Hans Bergsten
  • Release date: December 2000
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781565927469