The Session Service was created to allow Turbine based applications to access information about the current sessions in the application's context. Some of the most obvious uses would include

  • Count of the active sessions
  • Determine if a given user is already logged in on another session
  • Terminate a session

The service is implemented by using a listener configured in your application's deployment descriptor. The listener class is used by the container to notify the service when sessions are created or destroyed.


You will need to modify a few files in order to activate the service. The first modification will be in your TurbineResources.properties. See the example below for two settings that need to be present in order for the service to work.

# -------------------------------------------------------------------
#  S E R V I C E S
# -------------------------------------------------------------------
# Classes for Turbine Services should be defined here.
# Format: services.[name].classname=[implementing class]
# To specify properties of a service use the following syntax:
# service.[name].[property]=[value]

# -------------------------------------------------------------------
#  S E S S I O N  S E R V I C E
# -------------------------------------------------------------------


The next modification will be your application's deployment descriptor (web.xml). Here we will configure the listener class.

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">




There is also a pull tool available for accessing this service. To make it available for use in your velocity templates, add the following line to your TR.props file.

tool.session.sessionmgt = org.apache.turbine.services.session.SessionTool


The Session Service should be accessed through the org.apache.turbine.services.session.TurbineSession class or the pull tool. See the javadocs for both classes for more usage information.