BEA Systems, Inc.

WebLogic Server 5.1.0 API Reference

bea.jolt.pool.servlet
Class ServletSessionPool

java.lang.Object
  |
  +--bea.jolt.pool.Factory
        |
        +--bea.jolt.pool.SessionPool
              |
              +--bea.jolt.pool.servlet.ServletSessionPool

public class ServletSessionPool
extends SessionPool

This class provides a session pool for use in a Java servlet. A session pool represents one or more connections (sessions) to a BEA TUXEDO system. This class provides call methods that accept input parameters for a BEA TUXEDO service as a javax.servlet.http.HttpServletRequest object.

Refer to the base class SessionPool for information about session pools in general.

Author:
Copyright (c) 1999 by BEA Systems, Inc. All Rights Reserved.
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.

Method Summary
 ServletResult call(java.lang.String name, javax.servlet.http.HttpServletRequest request)
          Invokes a BEA TUXEDO service without an explicit transaction.
 ServletResult call(java.lang.String name, javax.servlet.http.HttpServletRequest request, Transaction tran)
          Invokes a BEA TUXEDO service.
protected  DataSet newDataSet(int initCapacity, boolean flag)
           
protected  Result newResult(int initCapacity)
           
protected  boolean useException()
          Allows exceptions to be thrown when an error occurs for servlets.
 
Methods inherited from class bea.jolt.pool.SessionPool
call, call, getConnection, getDefinition, getMaxConnections, isSuspended, log, setMaxConnections, startTransaction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

useException

protected boolean useException()
Allows exceptions to be thrown when an error occurs for servlets. It overrides the default base class behavior to suppress the exceptions.

Overrides:
useException in class bea.jolt.pool.Factory

call

public ServletResult call(java.lang.String name,
                          javax.servlet.http.HttpServletRequest request)
                   throws SessionPoolException,
                          ApplicationException,
                          ServiceException,
                          TransactionException
Invokes a BEA TUXEDO service without an explicit transaction. This is a convenience method and is equivalent to using the call(name, request, tran) method with tran set to null. The BEA TUXEDO service to be invoked is specified in the parameter name. Input parameters for the BEA TUXEDO service are passed to this method as a javax.servlet.http.HttpServletRequest object request. The names of the parameters in request must match the names of the BEA TUXEDO service input parameters. For HttpServletRequest parameters, the paramter names are the HTML form field names. Any HttpServletRequest parameter names that do not match the BEA TUXEDO service parameter names are ignored.

To represent BEA TUXEDO parameters with multiple occurrences, the name of a form field should have "_<index>" appended to it. Note that index numbers start at 0 (zero), so the first occurrence is represented by index 0 (zero). To indicate the first and second occurrences of a service parameter named "ACCOUNT_ID", sample HTML form fields could be written as follows:

 <FORM ACTION=myservlet METHOD=POST>
 ...
 <INPUT TYPE=TEXT NAME=ACCOUNT_ID_0>
 <INPUT TYPE=TEXT NAME=ACCOUNT_ID_1>
 ...
 </FORM>
 

If the session pool is suspended or if no connections are available, this method throws a SessionPoolException.

Specific exceptions are thrown to indicate error conditions. If an application error occurs, this method throws an ApplicationException. The return from the getResult method on ApplicationException can be cast to ServletResult, as below:

 // Assume ServletSessionPool (pool) has been initialized, and
 // request is a HttpServletRequest
 try
 {
    pool.call ("MY_SERVICE", request);
 }
 catch (ApplicationException e)
 {
	// Get the ServletResult
	ServletResult result = (ServletResult) e.getResult();
	// Access application data in result
	out.println("Application code is " + result.getApplicationCode());
	...
 }
 catch ... // Handle other exceptions
 ...
 }
 

Parameters:
name - Name of the BEA TUXEDO service to call
request - HttpServletRequest object
Returns:
A ServletResult object
See Also:
call(java.lang.String, javax.servlet.http.HttpServletRequest, bea.jolt.pool.Transaction), SessionPool.call(java.lang.String, bea.jolt.pool.DataSet, bea.jolt.pool.Transaction)

call

public ServletResult call(java.lang.String name,
                          javax.servlet.http.HttpServletRequest request,
                          Transaction tran)
                   throws SessionPoolException,
                          ApplicationException,
                          ServiceException,
                          TransactionException
Invokes a BEA TUXEDO service. The name of the BEA TUXEDO service to be invoked is specified in the parameter name. Input parameters for the BEA TUXEDO service are passed to this method as a javax.servlet.http.HttpServletRequest object request. The names of the members in request must match the names of the BEA TUXEDO service parameters. For input parameters, member names are the names of the HTML form field. Any members with names that do not match the BEA TUXEDO service parameter names are ignored.

To represent BEA TUXEDO parameters with multiple occurrences, the name of a member should have "_<index>" appended to it. Note that index numbers start at zero, so the first occurrence is represented by index zero (0). To indicate the first and second occurrences of a parameter named "ACCOUNT_ID", the member names should be "ACCOUNT_ID_0" and "ACCOUNT_ID_1" respectively.

To invoke multiple services in a transaction, create a Transaction object (see startTransaction()) and pass the Transaction object as the parameter to this method. If this service is not part of a transaction this parameter should be null.

If the session pool is suspended or if no connections are available, this method throws a SessionPoolException.

Parameters:
svcname - Name of the BEA TUXEDO service to be invoked
input - DataSet containing BEA TUXEDO service parameters, or null if no input parameters
tran - Transaction object, or null if no transaction
Returns:
A Result object, or null
See Also:
call(java.lang.String, javax.servlet.http.HttpServletRequest), SessionPool.call(java.lang.String, bea.jolt.pool.DataSet, bea.jolt.pool.Transaction), SessionPool.startTransaction(int)

newDataSet

protected DataSet newDataSet(int initCapacity,
                             boolean flag)

Overrides:
newDataSet in class SessionPool

newResult

protected Result newResult(int initCapacity)

Overrides:
newResult in class SessionPool

Documentation is available at
http://www.weblogic.com/docs51