BBjspSessionData

Creation Path

BBJSP| +--BBjspServletContext| +--BBjspSessionData

 

Description

In BBj 16.0 and higher, this class provides a repository for storing application data in a long-term session similar to a BBjspWebSession and a BBjHttpSession with the added benefit that the data is stored in a context-specific database.

A BBjspSessionData instance is available to BBJSP pages through the public field #BBjspSession! and is available to all BBJSP Widget objects used on BBJSP pages via the BBjspPageContext::getBBjspSession method.

The BBjspSessionData does not support adding BBj Custom objects as these are not serializable.

Creation

The BBjspSessionData is created through the following BBjspServletContext method:

Return Value

Method

BBjspSessionData

getBBjspSession()

Methods of BBjspSessionData

Return Value

Method

boolean

contains(string name)

Object

getAttribute(string name)

BBjVector

getAttributeNames()

string

getId()

long

getLastAccessedTime()

void

removeAttribute(string name)

void

setAttribute(string name, Object object)

Example

This example demonstrates how this works in a BBJSP servlet

CLASS PUBLIC MyServlet

    REM ===
    REM === You must implement this method as it is the main execution point.
    REM ===
    METHOD PUBLIC void service(BBjspServletContext context!)
        
        declare BBjspWebRequest request!
        declare BBjspWebResponse response!
        declare BBjspSessionData data!

        request! = context!.getRequest()
        response! = context!.getResponse()
        data! = #context!.getBBjspSession()

        s! = response!.getOutputStream()
        s!.write("<html>")
        s!.write("<body>")
        s!.write("<html><body><h1>Hello from BBJSP</h1>")
        s!.write(data!.getId())
        s!.write("</body>")
        s!.write("</html>")
        
    METHODEND
    
CLASSEND

See Also

BBJSP

BBJSP Session Data Overview

Pipeline Engine

BBjspWebRequest

BBjspWebResponse

BBjspWebSession