My Account
View Cart
Home
Community
Books & Videos
Safari Books Online
Conferences
Training
School of Technology
About
Complete List
Bestsellers
New Releases
Rough Cuts
Upcoming Titles
Ebooks
By Publisher
By Series
Out of Print
Order Info
Search
Search Tips
Tell a friend
Java Servlet & JSP Cookbook
By
Bruce W. Perry
January 2004
Pages: 746
|
Table of Contents
|
Index
|
Sample Chapter
|
Colophon
Table of Contents
Chapter 1
Writing Servlets and JSPs
Introduction
Writing a Servlet
Writing a JSP
Compiling a Servlet
Packaging Servlets and JSPs
Creating the Deployment Descriptor
Chapter 2
Deploying Servlets and JSPs
Introduction
Deploying an Individual Servlet on Tomcat
Using a Context Element in Tomcat'sserver.xml
Deploying an Individual Servlet on WebLogic
Deploying an Individual JSP on Tomcat
Deploying an Individual JSP on WebLogic
Deploying a Web Application on Tomcat
Deploying a Web Application on WebLogic Using Ant
Using the WebLogic Administration Console
Using WebLogic Builder to Deploy a Web Application
Using the weblogic.DeployerCommand-Line Tool
Chapter 3
Naming Your Servlets
Introduction
Mapping a Servlet to a Name in web.xml
Creating More Than One Mapping to a Servlet
Creating a JSP-Type URL for a Servlet
Mapping Static Content to a Servlet
Invoking a Servlet Without a web.xml Mapping
Mapping All Requests Within a Web Application to a Servlet
Mapping Requests to a Controller and Preserving Servlet Mappings
Creating Welcome Files for a Web Application
Restricting Requests for Certain Servlets
Giving Only the Controller Access to Certain Servlets
Chapter 4
Using Apache Ant
Introduction
Obtaining and Setting Up Ant
Using Ant Targets
Including Tomcat JAR files in the Build File Classpath
Compiling a Servlet with an Ant Build File
Creating a WAR File with Ant
Creating a JAR File with Ant
Starting a Tomcat Application with Ant
Stopping a Tomcat Application with Ant
Chapter 5
Altering the Format of JSPs
Introduction
Precompiling a JSP in Tomcat
Precompiling a JSP in WebLogic
Precompiling JSPs with the Precompilation Protocol
Mapping a JSP to Its Page Implementation Class
Creating a JSP from Scratch as a JSP Document
Generating an XML View from a JSP
Chapter 6
Dynamically Including Content in Servlets and JSPs
Introduction
Including a Resource Each Time a Servlet Handles a Request
Using an External Configuration to Include a Resource in a Servlet
Including Resources Nested at Multiple Levels in a Servlet
Including a Resource that Seldom Changes into a JSP
Including Content in a JSP Each Time the JSP Handles a Request
Using an External Configuration File to Include a Resource in a JSP
Including an XML Fragment in a JSP Document
Including Content from Outside a Context in a JSP
Chapter 7
Handling Web Form Data in Servlets and JSPs
Introduction
Handling a POST HTTP Request in a Servlet
Handling a POST HTTP Request in a JSP
Setting the Properties of a JavaBean in a JSP
Setting a Scoped Attribute in a JSP to the Value of a Form Parameter
Posting Data from a Servlet
Posting Data from a JSP
Using a Servlet to Add a Parameter to a Query String
Using a JSP to Add a Parameter to a Query String
Using a Filter to Read Parameter Values
Chapter 8
Uploading Files
Introduction
Preparing the HTML Page for File Uploads
Using the com.oreilly.servlet Library
Uploading One File at a Time
Uploading Multiple Files
Renaming Files
Using a JSP to Handle a File Upload
Chapter 9
Handling Exceptions in Web Applications
Introduction
Declaring Exception Handlers in web.xml
Creating an Exception-Handling Servlet
Sending an Error from a Servlet
Sending an Error from a JSP
Creating an Error-Handling JSP
Declaring a Special Exception-Handling JSP for Other JSPs
Chapter 10
Reading and Setting Cookies
Introduction
Setting a Cookie with a Servlet
Creating an Array from All of the Request's Cookies
Setting a Cookie with a JSP
Reading Cookie Values with a Servlet
Reading Cookie Values with a JSP
Altering or Removing a Cookie That Has Already Been Set
Chapter 11
Session Tracking
Introduction
Setting the Session Timeout in web.xml
Setting the Session Timeout in All Tomcat Web Applications
Setting the Session Timeout Programmatically
Checking if a Session Exists in an HttpServletRequest
Tracking Session Activity in Servlets
Tracking Session Activity in JSPs
Using URL Rewriting in a JSP
Using URL Rewriting in a Servlet
Using a Listener to Track the Session Lifecycle
Using a Listener to Monitor Session Attributes
Using a Filter to Monitor Session Attributes
Chapter 12
Integrating JavaScript with Servlets and JSPs
Introduction
Including JavaScript Modules in a Servlet
Including JavaScript Modules in a JSP
Creating a New Window with JavaScript in a Servlet
Creating a New Window with JavaScript in a JSP
Using JavaScript to Validate Form Values in a Servlet
Using JavaScript to Validate Form Values in a JSP
Chapter 13
Sending Non-HTML Content
Introduction
Sending a PDF File
Sending a Word Processing File
Sending an XML file
Sending an Audio File
Viewing Internal Resources in a Servlet
Chapter 14
Logging Messages from Servlets and JSPs
Introduction
Logging Without Log4j
Setting Up Log4j
Using a Logger Without a Configuration File
Adding an Appender to the Root Logger
Using a Pattern with a Logger's Appender
Using log4j in a JSP
Logging Messages Using a Servlet Context Event Listener
Logging Messages Using a Session Event Listener
Chapter 15
Authenticating Clients
Introduction
Creating Users and Passwords with Tomcat
Setting Up SSL on Tomcat
Using BASIC Authentication
Using Form-Based Authentication
Logging Out a User
Using JAAS to Create a LoginModule
Creating the JAAS Configuration File
Using JAAS in a Servlet
Using JAAS in a JSP
Chapter 16
Binding, Accessing, and Removing Attributes in Web Applications
Introduction
Setting ServletContext Attributes in Servlets
Setting ServletContext Attributes in JSPs
Accessing or Removing ServletContext Attributes in Servlets
Accessing or Removing ServletContext Attributes in JSPs
Setting Session Attributes in Servlets
Setting Session Attributes in JSPs
Accessing or Removing Session Attributes in Servlets
Accessing or Removing Session Attributes in JSPs
Setting Request Attributes in Servlets
Setting Request Attributes in JSPs
Accessing or Removing Request Attributes in Servlets
Accessing or Removing Request Attributes in JSPs
Chapter 17
Embedding Multimedia in JSPs
Introduction
Embedding an Applet in a JSPUsing jsp:plugin
Embedding an Applet in a JSP Using the HTML Converter
Automatically Creating HTML Template for Including Flash Files
Writing HTML Template to Embed a Flash File
Embedding Flash in a Servlet
Embedding a QuickTime Movie in a JSP
Embedding an SVG File in a JSP
Embedding a Background Soundtrack in a JSP
Chapter 18
Working With the Client Request
Introduction
Examining HTTP Request Headers in a Servlet
Examining HTTP Request Headers in a JSP
Using a Filter to Alter Request Headers
Automatically Refreshing a Servlet
Automatically Refreshing a JSP
Counting the Number of Web Application Requests
Chapter 19
Filtering Requests and Responses
Introduction
Mapping a Filter to a Servlet
Mapping a Filter to a JSP
Mapping More Than One Filter to a Servlet
Changing the Order in Which Filters are Applied to Servlets
Configuring Initialization Parameters for a Filter
Optionally Blocking a Request with a Filter
Filtering the HTTP Response
Using Filters with RequestDispatcher Objects
Checking Form Parameters with a Filter
Blocking IP Addresses with a Filter
Chapter 20
Managing Email in Servlets and JSPs
Introduction
Placing the Email-Related Classes on your Classpath
Sending Email from a Servlet
Sending Email from a Servlet Using a JavaBean
Accessing Email from a Servlet
Accessing Email from a Servlet Using a JavaBean
Handling Attachments from an Email Received in a Servlet
Adding Attachments to an Email in a Servlet
Reading a Received Email's Headers from a Servlet
Chapter 21
Accessing Databases
Introduction
Accessing a Database from a Servlet Without DataSource
Configuring a DataSource in Tomcat
Using a DataSource in a Servlet with Tomcat
Creating a DataSource on WebLogic
Using a JNDI Lookup to get a DataSource from WebLogic
Using a DataSource from WebLogic in a JSP
Calling a Stored Procedure from a Servlet
Calling a Stored Procedure from a JSP
Converting a ResultSet to a Result Object
Executing Several SQL Statements Within a Single Transaction
Using Transactions with JSPs
Finding Information about a ResultSet
Chapter 22
Using Custom Tag Libraries
Introduction
Creating a Classic Tag Handler
Creating a JSP 1.2 TLD for a Classic Tag Handler
Creating a JSP 2.0 TLD for a Classic Tag Handler
Packaging a Tag Library in a Web Application
Packaging the Tag Library in a JAR File
Using the Custom Tag in a JSP
Handling Exceptions in a Custom Tag Class
Creating a Simple Tag Handler
Creating a TLD for a Simple Tag Handler
Using a Simple Tag Handler in a JSP
Creating a JSP Tag File
Packaging the JSP Tag File in a Web Application
Packaging the JSP Tag File in a JAR
Using a Custom Tag Associated with a Tag File
Adding a Listener Class to a Tag Library
Chapter 23
Using the JSTL
Introduction
Downloading the JSTL 1.0 and Using the JSTL Tags in JSPs
Downloading the Java Web Services Developer Pack
Using the Core JSTL Tags
Using the XML Core JSTL Tags
Using the XML Transform Tags
Using the Formatting JSTL Tags
Using A SQL JSTL Tag with a DataSource Configuration
Using A SQL JSTL Tag Without a DataSource Configuration
Accessing Scoped Variables with the EL
Accessing Request Parameters with the EL
Using the EL to Access Request Headers
Using the EL to Access One Request Header
Accessing Cookies with the EL
Using the EL to Access JavaBean Properties
Using JSTL Functions
Chapter 24
Internationalization
Introduction
Detecting the Client Locale in a Servlet
Detecting the Client's Locales in a JSP
Creating a ResourceBundle as a Properties File
Creating a ResourceBundle as a Java Class
Using the ResourceBundle in a Servlet
Using the ResourceBundle in a JSP
Formatting Dates in a Servlet
Formatting Dates in a JSP
Formatting Currencies in a Servlet
Formatting Currencies in a JSP
Formatting Percentages in a Servlet
Formatting Percentages in a JSP
Setting the Localization Context in the Deployment Descriptor
Chapter 25
Using JNDI and Enterprise JavaBeans
Introduction
Configuring a JNDI Object in Tomcat
Accessing the Tomcat JNDI Resource from a Servlet
Accessing the Tomcat JNDI Resource from a JSP
Configuring a JNDI Resource in WebLogic
Viewing the JNDI Tree in WebLogic
Accessing the WebLogic JNDI Resource from a Servlet
Accessing the WebLogic JNDI Resource from a JSP
Accessing an EJB Using the WebLogic JNDI Tree
Chapter 26
Harvesting Web Information
Introduction
Parsing an HTML Page Using thejavax.swing.text Subpackages
Using a Servlet to Harvest Web Data
Creating a JavaBean as a Web Page Parser
Using the Web Page Parsing JavaBean in a Servlet
Using the Web Page Parsing JavaBean in a JSP
Chapter 27
Using the Google and Amazon Web APIs
Introduction
Getting Set Up with Google's Web API
Creating a JavaBean to Connect with Google
Using a Servlet to Connect with Google
Using a JSP to Connect with Google
Getting Set Up with Amazon's Web Services API
Creating a JavaBean to Connect with Amazon
Using a Servlet to Connect with Amazon
Using a JSP to Connect with Amazon
Colophon
Return to
Java Servlet & JSP Cookbook