# About JSP Pages and Application Module Pooling

The JSP pages access business components through instances of the application module. You can decide how application module instances are allocated during the JSP session, whether their state is preserved, and whether there is failover support from the database. The default application module pooling implementation in the Business Components for Java framework supports three modes:

- Stateful

- Stateless (the default mode for all JSP pages)

- Reserved

In a JSP application you can control the manner in which a databound JSP page releases its application module instance at two levels:

- At the level of the entire JSP application by setting the RELEASE_MODE property in the configuration you create for an application module

- At the level of individual JSP pages by setting the ReleasePageResources data tag

- At the level of individual JSP pages by setting the `setReleaseApplicationResources()` method in JSP pages that rely on data web beans to connect to the application module

Note: The mode you specify for the ReleasePageResources data tag or `setReleaseApplicationResources()` method, overrides the JSP application release mode at the level of individual JSP pages. However, we do not recommend mixing data tags and data web beans on the same JSP page.

#### About Application Module State Management in Data Tag Based Applications

During page processing, the HTTP requests for a page share a limited pool of instances of each application module. In a stateless JSP application, access to a specific instance of the application module is maintained only for the duration of the page requests. Then, when the ReleasePageResources data tag with Stateless option is processed, the application module instance must be released back to the pool of instances of that application module.

If you allow the default stateless option for individual JSP pages or the entire JSP application, the data tags do not necessarily access the same application module instance each time a new page is invoked during a specific HTTP session and, therefore, cannot depend on a view object's rowset remaining the same from one invocation to the next. This behavior is desirable when your JSP pages work independently from one another, and do not represent a single task that requires state to be maintained. Permitting the majority of your JSP pages to release the application module instance statelessly reduces the overhead that managing application module state entails and ensures that your JSP application will operate at the highest level of performance possible.

When you select the Stateful option for the ReleasePageResources data tag, the data tags of a JSP application also do not access the same application module instance each time they are invoked. However, unlike stateless JSP pages, Business Components for Java saves the application module state to the database when the application module is released, and allows a view object's rowset to remain the same from one invocation to the next. Stateful mode is the preferred choice when:

- You want to preserve information across a series of JSP pages that users interact with to complete a single task

- You want to preserve changes submitted by the user from one page to the next

In stateful mode, Business Components for Java provides failover support from the database, and permits the application module pool to be used efficiently. The application module pool manager manages the application state including the current position and all dynamic application information that needs to be passed from one JSP page to the next. Stateful mode is useful whether or not the user submits changes to the data: it is easier and more efficient to let Business Components for Java manage restoring queries to the previous HTTP request than performing these tasks programmatically using the Business Components for Java API.

Important: If you do permit users to modify data in stateful or reserved mode, you must use the Commit data tag to submit the changes to the database.

When you select the Reserved option for the ReleasePageResources data tag, once a data tag has connected to an application module, all subsequent connections to that application module from any data tag during the same HTTP session involve the same instance of the application module. This holds true whether a subsequent connection is from another JSP page or from a new invocation of the same JSP page. This mode is similar to the stateful application, but it does not provide failover support, nor does it permit application modules to be recycled. Reserved mode is provided primarily for compatibility with application modules when non-standard JDBC connections have been defined.

#### Related Topic

About Application Module Pooling