beautypg.com

When do you need to store state – Apple WebObjects 3.5 User Manual

Page 112

background image

Chapter 7

Managing State

112

Storing state information on the server. With each transaction, the web
application locates the state information associated with a request from a
particular client. The state information might be stored in memory, in a file
on disk, or in a standard database, depending on the application.

Passing state back to the client with every transaction simplifies the accounting
associated with state management but is inefficient and can constrain the design
of your site. Storing state on the server, on the other hand, requires sophisticated
applications that can keep track of per-session information no matter how many
users are accessing the application simultaneously. However, without support
from your programming environment, storing state on the server is not an
attractive option.

As you’ll see in this chapter, WebObjects lets you easily make use of any of these
state-storage solutions. For a given application, state management can be as
simple as selecting the management strategy you want to use and identifying
the information that you want stored on a per-session basis. The WebObjects
framework does the rest no matter how many users will be accessing the
application simultaneously.

When Do You Need to Store State?

Web applications that store state information are somewhat more complex than
those that don’t. State storage can also raise performance and scalability issues
(such as how much physical storage an application server should have for a given
number of simultaneous users). Given these considerations, it’s clearly best to
avoid storing state.

Applications differ widely in their state storage requirements. At one extreme
are simple applications that vend read-only pages (company information,
specifications for hardware devices, and so on). These traditional World Wide
Web applications don’t need to store state information. At the other extreme are
commercial applications that let users wheel virtual shopping carts from page to
page, selecting items for purchase. These applications must keep track of order
information on a per-user basis. Considering that a popular site could have
scores of simultaneous sessions, these commercial applications must employ a
sophisticated means of handling state for each session. Somewhere between
these extremes are applications with simple state storage requirements, such as
keeping track of the total number of votes on an issue, the number of visitors to
the web site, and so on.