Top

Managing State


Most applications must be able to preserve some application state between a user's requests. For example, if you're writing a catalog application, you must keep track of the items that the user has selected before the user actually fills out the purchasing information. By default, WebObjects stores application state on the server. If this doesn't meet your needs, WebObjects provides several alternatives strategies for storing state.

This chapter describes why, when, and how to store state in a WebObjects application. It compares all of the available state-storage strategies, shows you how to implement your own state-storage strategy, plus it describes how to control the amount of application state stored.

If you're fairly new to WebObjects programming, you'll probably just want to read the first three sections of this chapter and skip the rest. As you begin to write larger, more complex applications, memory demands and performance become an issue. At that point, you should read the rest of this chapter to learn about alternative state-storage strategies and how you can control the amount of state stored.

Before reading this chapter, you should be familiar with concepts presented in the chapter "WebObjects Viewed Through Its Classes."

Why Do You Need to Store State

When Do You Need to Store State

Objects and State
The Application Object and Application State
The Session Object and Session State
Component Objects and Component State

State Storage Strategies
Comparison of Storage Options
A Closer Look at Storage Strategies
State in the Server
State in the Page
State in Cookies
Custom State-Storage Options

Storing State for Custom Objects
Archiving Custom Objects in a Database Application
Archiving Custom Objects in Other Applications

Controlling Session State
Setting Session Time-Out
Using awake and sleep

Controlling Component State
Managing Component Resources
Adjusting the Page Cache Size
Using awake and sleep
pageWithName: and Page Caching
Client-Side Page Caching
Page Refresh and WODisplayGroup

First Section