JSP Tutorials - Herong's Tutorial Examples

https://www.herongyang.com/JSP

Copyright © 2006-2022 Herong Yang. All rights reserved.

JSP Tutorial This book is a collection of notes and sample codes written by the author while he was learning JSP (JavaServer Pages). Topics include Tomcat installation and configuration to support JSP; JSP execution context, JSP elements, and sessions; Using JavaBean Classes; Cookie management; Controlling HTTP Response Header Lines; Supporting non-ASCII characters and localization; Debugging and measuring performance; Using EL (Expression Language); JSTL (JSP Standard Tag Library) syntax and Tag Java interface; Managing file uploads. Updated in 2022 (Version v5.11) with minor changes.

Table of Contents

About This Book

JSP (JavaServer Pages) Overview

What Is JSP (JavaServer Pages)

JSP Releases and Changes

Main Features of JSP

How JSP Pages Are Processed

Popular JSP Enabled Web Servers

Tomcat Installation on Windows Systems

Downloading and Installing Tomcat

Launching Tomcat Server

Verifying Tomcat Server

Setting Up Tomcat Server Admin Access

Reviewing Tomcat Server Status Page

Tomcat Web Application Manager

My First HTML Page - hello.html

My First JSP Page - hello.jsp

JSP Scripting Elements

What Are Scripting Elements

Converting JSP Pages with Scripting Elements

Example JSP Page with Scripting Elements

Example Java Class Converted from a JSP Page

Mixing Static Data with Scriptlets for Compound Statements

Java Servlet Introduction

What Is Servlet

Creating and Deploying a Servlet on Tomcat

Relationship between Servlet and JSP

Modifying the Servlet Converted from a JSP Page

JSP Implicit Objects

What Are Implicit Objects

Information of JSP Execution Context

Information from "request" Object

Methods Supported by the "session" Object

Syntax of JSP Pages and JSP Documents

Syntactic Elements of a JSP Page

JSP Document - JSP Page in XML Format

JSP Document - JSP Version Error

Writing Scriptlet Element in XML Format

Writing Directive Element in XML Format

Writing Action Element in XML Format

"include" Directive and Action Elements

Execution Result of CurrentTime.jspx

JSP Application Session

What Is a Session

The "session" Implicit Object

Passing Values between JSP Pages

Testing Result of RegForm.jspx

Using Perl LWP Package for Debugging

Managing Cookies in JSP Pages

What Is a Cookie

Sending and Receiving Cookies in JSP Pages

Persistent Cookies Stored on Hard Disk

Persistent Cookie Test Example

Space Character not Allowed in Cookie Value

Dumping HTTP Response with Cookies

JavaBean Objects and "useBean" Action Elements

What Is a JavaBean

"jsp:useBean" Action Elements

"jsp:useBean" Requires Fully Qualified Class Name

Servlet Class Converted from UseBean.jspx

Setting and Getting JavaBean's Properties

Using JavaBean Objects in Scripting Elements

Using Java Objects as JavaBeans

getProperty() Error on Tomcat 7

Refreshing Loaded JavaBean Classes

Importing Unnamed Package Class Error

Using JavaBean without Import Element Error

Creating JavaBean Classes in Named Packages

"NoClassDefFoundError" Exception

Managing HTTP Response Header Lines

Non-ASCII Characters Support in JSP Pages

Characters Traveling from JSP Files to Browser Screens

Handling ASCII Characters in JSP Pages

Presenting Non ASCII Characters in HTML Documents

Entering Non ASCII Characters in JSP Pages

Java Strings as non-Unicode Encoded Byte Sequences

Java Strings as Unicode Encoded Byte Sequences

Entering Non-ASCII Characters as Static Text

Static HTML Text in HTML Page

Static HTML Text in JSP Page in Standard Syntax

Static HTML Text in JSP Page in XML Syntax

Supporting Characters in Multiple Languages

Performance of JSP Pages

Performance of Calculating Prime Numbers

Performance of Loading JSP Pages

EL (Expression Language)

Overview of JSTL (JSP Standard Tag Libraries)

What is JSTL

Installing GlassFish JSTL on Tomcat

"Hello world!" with JSTL

JSTL in XML Style JSP Pages

General Syntax of JSTL Tags

NoClassDefFoundError - LoopTag/ForEachTag

Installing JSTL 1.2 API JAR File

JSTL Example - Loop Tag on Map Objects

JSTL Core Library

What Is JSTL Core Library

c:out Action Tag

c:out Action Tag with EL Expressions

c:set Action Tag

c:if Action Tag

c:choose Action Tag

c:forEach Action Tag

c:forTokens Action Tag

Example - Dumping EL Implicit Objects

Example - Calculating Prime Numbers

JSP Custom Tags

What Is Custom Tag

Creating and Using Custom Tags

My First Custom Tag - hy:hello

How Custom Tag Works

JSP Java Tag Interface

javax.servlet.jsp.tagext.* Package

javax.servlet.jsp.tagext.IterationTag Interface

IterationTag Interface Test Class - TraceTag.java

IterationTag Interface Test JSP - TraceTagTest.jspx

Servlet Class Converted from JSP - TraceTagTest_jsp.java

TagSupport Class - Dummy Implementation of IterationTag

Custom Tag Attributes

Multiple Tags Working Together

Nested Tags Example - Break Tag for Loops

Sharing Data with Other Tags

File Upload Test Application

Using Tomcat on CentOS Systems

Download and Install Tomcat on CentOS

Start/Stop Tomcat Server on CentOS

My First HTML Page on CentOS

My First JSP Page on CentOS

My First Servlet Page on CentOS

Using Tomcat on macOS Systems

Download and Install Tomcat on macOS

Start/Stop Tomcat Server on macOS

My First HTML Page on macOS

My First JSP Page on macOS

My First Servlet Page on macOS

Connecting to SQL Server from Servlet

SQL Server Connection Requirements

Download and Install SQL Server JDBC Driver

Test SQL Server JDBC Driver

Use JDBC Driver in Servlet

Load JDBC Driver Class in Servlet

Developing Web Applications with Servlet

Archived Tutorials

Archived: Installing GlassFish JSTL 1.2 on Tomcat

Archived: Downloading and Installing Tomcat 7

Archived: Installing Tomcat 5.5.7

Archived: Installing Tomcat 4.1.18

Archived: Java Class Converted by Tomcat 4.1.18

Archived: Hijacking Servlet Converted from JSP

Archived: Using Perl LWP::Debug Module to Debug

Archived: Installing JSTL 1.0 Apache Implementation

Archived: Upgrade JDK 1.3 to JDK 1.4 on Tomcat 4.1

Archived: Compilation Errors with JDK 1.4

Archived: Using JavaBean without Import Element Error

References

Full Version in PDF/EPUB

Keywords: JSP, JavaServer Page, Web, Tutorial