Sun Logo


Javatrademark Servlet Specification

Java Cardtrademark Platform, Version 3.0.1

Connected Edition

5-30-09



Contents

Figures

Tables

Code Examples

Preface

1. Architecture Overview

1.1 Definition of a Servlet

1.2 Definition of a Servlet Container

1.3 Example of Servlet Invocation

1.4 Compatibility With Java Servlet Specification Version 2.4

1.4.1 Features Not In The Java Card Platform Version

1.4.2 Backward Compatibility Support of Web Applications

1.4.3 Temporary Working Directories

1.4.4 SSL Attributes

1.4.5 Removed Elements of the Deployment Descriptor

1.4.5.1 Removed Elements for Deployment in Web Container JSP Pages Enabled or Part of a Java EE Application Server

1.4.5.2 distributable Element Removed

1.4.5.3 run-as Element Removed

1.4.5.4 dispatcher Element Removed

1.4.5.5 auth-method Element Value CLIENT-CERT Removed

1.4.6 realm-name Element Extended Applicability

1.4.7 Filtering of Authorization Request Header

1.4.8 Web Application Deployment Hierarchy and Directory Structure

1.4.9 Usage of URL Patterns for Servlet Mapping, Filter Mapping and Security Constraints Restricted

1.4.10 Combination of Security Constraints Precluded

1.4.11 Default Servlet Implementation

1.4.12 Classes, Interfaces and Methods Depending on API Not Supported on the Java Card Platform

1.4.12.1 java.io.Serializable Implementation Removed

1.4.12.2 java.lang.Cloneable Implementation Removed

1.4.12.3 HttpSessionActivationListener Interface Removed

1.4.12.4 ServletContext methods getResource and getResourcePaths Removed

1.4.12.5 ServletRequest and ServletRequestWrapper method getParameterMap Removed

1.4.12.6 getUserPrincipal method of HttpServletRequest and HttpServletRequestWrapper Removed

1.4.12.7 ServletOuputStream methods print(float), print(double), println(float) and println(double) Removed

1.4.13 Removed Classes, Interfaces and Methods Deprecated in Java Servlet API Specification Version 2.4

1.4.13.1 SingleThreadModel Interface Removed

1.4.13.2 HttpSessionContext Interface Removed

1.4.13.3 HttpUtils Class Removed

1.4.13.4 ServletContext methods getServlet, getServletNames, getServlets, and log Removed

1.4.13.5 getRealPath method of ServletRequest and ServletRequestWrapper Removed

1.4.13.6 UnavailableException constructors and method getServlet Removed

1.4.13.7 isRequestedSessionIdFromUrl method of HttpServletRequest and HttpServletRequestWrapper Removed

1.4.13.8 HttpServletResponse and HttpServletResponseWrapper methods encodeRedirecUrl, encodeUrl and setStatus Removed

1.4.13.9 HttpSession methods getSessionContext, getValue, getValueNames, putValue and removeValue Removed

1.4.13.10 Attributes Deprecated or Redundant in Java Servlet API Specification Version 2.4

2. The Servlet Interface

2.1 Request Handling Methods

2.1.1 HTTP Specific Request Handling Methods

2.1.2 Additional Methods

2.1.3 Conditional GET Support

2.2 Number of Instances

2.3 Servlet Life Cycle

2.3.1 Loading and Instantiation

2.3.2 Initialization

2.3.2.1 Error Conditions on Initialization

2.3.2.2 Tool Considerations

2.3.3 Request Handling

2.3.3.1 Multithreading Issues

2.3.3.2 Exceptions During Request Handling

2.3.3.3 Thread Safety

2.3.4 End of Service

3. Servlet Context

3.1 Introduction to the ServletContext Interface

3.2 Scope of a ServletContext Interface

3.3 Initialization Parameters

3.4 Context Attributes

3.5 Resources

3.6 Multiple Hosts and Servlet Contexts

4. The Request

4.1 HTTP Protocol Parameters

4.1.1 When Parameters Are Available

4.2 Attributes

4.3 Headers

4.4 Request Path Elements

4.5 Path Translation Methods

4.6 Cookies

4.7 SSL Attributes

4.8 Internationalization

4.9 Request Data Encoding

4.10 Lifetime of the Request Object

5. The Response

5.1 Buffering

5.2 Headers of an HTTP Response

5.3 Convenience Methods

5.4 Internationalization

5.5 Closure of Response Object

5.6 Lifetime of the Response Object

6. Filtering

6.1 What is a Filter?

6.1.1 Examples of Filtering Components

6.2 Main Concepts of Filtering

6.2.1 Filter Life Cycle

6.2.2 Wrapping Requests and Responses

6.2.3 Filter Environment

6.2.4 Configuration of Filters in a Web Application

6.2.5 Filters and the RequestDispatcher

7. Sessions

7.1 Session Tracking Mechanisms

7.1.1 Cookies

7.1.2 SSL Sessions

7.1.3 URL Rewriting

7.1.4 Session Integrity

7.2 Creating a Session

7.3 Session Scope

7.4 Binding Attributes into a Session

7.5 Session Timeouts

7.6 Last Accessed Times

7.7 Important Session Semantics

7.7.1 Threading Issues

7.7.2 Client Semantics

8. Dispatching Requests

8.1 Obtaining a RequestDispatcher

8.1.1 Query Strings in Request Dispatcher Paths

8.2 Using a Request Dispatcher

8.3 The Include Method

8.3.1 Included Request Parameters

8.4 The Forward Method

8.4.1 Query String

8.4.2 Forwarded Request Parameters

8.5 Error Handling

9. Web Applications

9.1 Web Applications Within Web Servers

9.2 Relationship to ServletContext

9.2.1 Elements of a Web Application

9.3 Deployment Hierarchies

9.4 Directory Structure

9.4.1 Example of Application Directory Structure

9.5 Web Application Archive File

9.6 Web Application Deployment Descriptor

9.6.1 Dependencies On Libraries External to WAR File

9.6.2 Web Application Class Loader

9.7 Error Handling

9.7.1 Request Attributes

9.7.2 Error Pages

9.8 Welcome Files

9.9 Web Application Deployment

10. Application Life Cycle Events

10.1 Event Listeners

10.1.1 Event Types and Listener Interfaces

10.1.2 An Example of Listener Use

10.2 Listener Class Configuration

10.2.1 Provision of Listener Classes

10.2.2 Deployment Declarations

10.2.3 Listener Registration

10.2.4 Notifications At Shutdown

10.3 Deployment Descriptor Example

10.4 Listener Instances and Threading

10.5 Listener Exceptions

10.6 Session Events

11. Mapping Requests To Servlets

11.1 Use of URL Paths

11.2 Specification of Mappings

11.2.1 Implicit Mappings

11.2.2 Example Mapping Set

12. Security

12.1 Introduction

12.2 Declarative Security

12.3 Programmatic Security

12.4 Roles

12.5 Authentication

12.5.1 HTTP Basic Authentication

12.5.2 HTTP Digest Authentication

12.5.3 Form-Based Authentication

12.5.3.1 Login Form Notes

12.6 Server Tracking of Authentication Information

12.7 Specifying Security Constraints

12.7.1 Combining Constraints

12.7.2 Example of Applicable Constraints

12.7.3 Processing Requests

12.8 Default Policies

12.9 Login and Logout

13. Deployment Descriptor

13.1 Deployment Descriptor Elements

13.2 Rules for Processing the Deployment Descriptor

13.3 Deployment Descriptor

13.4 Deployment Descriptor Element Structure

13.4.1 web-app Element

13.4.2 description Element

13.4.3 display-name Element

13.4.4 icon Element

13.4.5 context-param Element

13.4.6 filter Element

13.4.7 filter-mapping Element

13.4.8 listener Element

13.4.9 servlet Element

13.4.10 servlet-mapping Element

13.4.11 session-config Element

13.4.12 mime-mapping Element

13.4.13 welcome-file-list Element

13.4.14 error-page Element

13.4.15 security-constraint Element

13.4.16 login-config Element

13.4.17 security-role Element

13.4.18 locale-encoding-mapping-list Element

13.5 Examples of Deployment Descriptor Usage

13.5.1 A Basic Example

13.5.2 An Example of Security

Glossary

Index