BBJSP Session Data Overview (Deprecated)

The BBJSP system is deprecated. For new development, use BBxServlet.

Description

In BBj 16.0 and higher, the BBJSP framework persistent storage for Session Data which is available to BBJSP pages, commands and pipelines. Unlike HTTP session data, BBJSP session data persists across multiple site visits and allows the developer to maintain long-term state.

Each Jetty context can be configured to use a different database or to share the global BBJSP session database.

How to access the BBjspSessionData object?

The BBjspSessionData is loosely connected to the http session via a browser cookie and will be available to all your components.

Pages

Each BBJSP Page has an implicit object which can be used in scriptlets to read/write data in the BBjspSessionData object. This object is accessible with the public field BBjspSession.

Commands

When a BBJSP Commands is executed an instance of BBjspCommandContext is supplied to the BBjspCommand::execute(BBjspCommandContext) method which provides the BBjspCommandContext::getBBjspSession() method.

Page Widgets

Widget can be used within a BBJSP page and opened by the page giving access to the BBjspPageContext::getBBjspSession() method. Read more about BBJSP Widget Overview.

Configuring the BBjspSessionData

BBjspSessionData uses a database for storage. The database is configured through the web-config.xml which can be placed within the WEB-CFG folder of your BBJSP project. When a BBJSP enabled context does not have it's own web-config.xml then the default basis/cfg/web-config.xml will be used.

To configure a new data-source for BBJSP Session storage you must first create a database, the easiest way to achieve this will be to make a copy if the existing one in the basis/bbjsp/data and basis/bbjsp/dd folders then add the configuration using Enterprise Manager. Alternatively you can execute the following script to generate the database.

CREATE TABLE SESSION_DATA_TABLE (SESSION_ID VARCHAR(32) NOT NULL, SESSION_DATA BLOB NOT NULL, UPDATED_DATE TIMESTAMP NOT NULL) ESQL;
ALTER TABLE SESSION_DATA_TABLE ADD CONSTRAINT pkSESSION PRIMARY KEY (SESSION_ID)

Once you have the database created you should configure the context to use the new database. To do that, copy /basis/cfg/web-config.xml into /your/context/WEB-CFG folder and change the <database> within <db-config> and the table parameter within <object-persister>. Here is an extract from the file to show you what needs changing:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<context-config version="1.0">
...
   <bbj-sessions>
        <db-config>
            <driver-classname>com.basis.jdbc.BasisDriver</driver-classname>
            <url>jdbc:basis:localhost:2001</url>
            <database>MY_DATABASE</database>
            <user>admin</user>
            <password encoded="true">EcVDAp9BgKI5v4TCE/xOpQ==</password>
        </db-config>
        <object-persister>
            <table>PIPELINE_SESSION</table>
            <idColumn>SESSION_ID</idColumn>
            <dataColumn>SESSION_DATA</dataColumn>
            <timeStampColumn>UPDATED_DATE</timeStampColumn>
        </object-persister>
...
    </bbj-sessions>
...
</context-config> 

BBjspSessionData and Pipelines

Pipelines are used to automate some business process. During execution, the BBj program does not have access to the BBjspWebSession or the BBjspWebRequest that may have triggered the pipeline. Pipelines rely upon the BBjspSessionData object and should interact with the data it contains.

See Also

BBJSP

BBJSP Session Data Overview

Pipeline Engine

BBJSP Widget Overview