SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 130 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

This initialization can be accomplished
with a servlet that is guaranteed to be loaded at server startup by the
load-on-startup element of web.xml (see Section 2.6). The initialization
can also be accomplished with the ServletContextListener??™s
contextInitialized method. For example, if several
pages in your application need a drop-down box with a prefilled list of
countries that are stored in a database, you can initialize and store this
list in the ServletContext inside the contextInitialized
method of the ServletContextListener. For a detailed discussion
of listeners, please see Chapter 6 (The Application Events
Framework).
3. Objects stored in HttpSession must implement Serializable.
The servlet specification requires compliant Web containers to support
migration of objects stored in the HttpSession that implement the
Serializable interface. If the objects stored in the HttpSession do
not implement the Serializable interface, the container may fail
to migrate the session. If this failure happens, the container will throw
an IllegalArgumentException. Also note that the class implementing
the Serializable interface has to follow regular serialization
guidelines. For more information, please go to http://java.sun.com/
j2se/1.5.0/docs/guide/serialization/.
4. Only minimal information should be stored in HttpSession.
For a clustered environment to function as a single Web application,
the data stored in the HttpSession must be kept in sync with the
other servers in the cluster.


Pages:
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142