Chapter 5. BEAWEB Components for Microsoft Active Server Pages

The BEAWEB components contain the objects specific for Microsoft Active Server Pages (ASP). These objects are:

SessionPoolManager Object

This object provides a session pool factory for the Microsoft specific SessionPool object.

BEAWEB.SessionPoolManager Component

The following component creates an instance of the SessionPoolManager object.

Synopsis

Server.CreateObject ("BEAWEB.SessionPoolManager")

Usage

Create a SessionPoolManager object.

SessionPoolManager Methods

The following methods are used in conjunction with the SessionPoolManager object:

done

Synopsis

done()

Usage

Done with this session manager. Stops all session pools and terminates all active connections immediately.

createSessionPool

Synopsis

int createSessionPool(String addrs[], String saddrs[], int minCons, int maxCons, UserInfo usr, String id)

Parameters

addrs
A list of primary server addresses.

saddrs
A list of secondary server addresses for failover.

minCons
The minimum number of connections to start with.

maxCons
The maximum number of connections in this pool.

usr
The TUXEDO authentication information, or null.

id
Reserved for future use. Must be null.

Usage

Create a session pool with multiple restartable connections. The caller provides a unique ID to identify the session pool. If a connection in the session pool is terminated unexpectedly, a new connection will be established to keep the session pool alive. A session pool provides load-balancing among connections and failover capability by letting the user specify a primary server address list and a secondary server address list. The id must be null for this release.

Returns

The number of successful connections.

suspendSessionPool

Synopsis

suspendSessionPool(String id, boolean action)

Parameters

id
Reserved for future use. Must be null.

action
true to suspend the session pool; false to resume it.

Usage

Suspend this session pool so it will not accept any new requests. It allows the administrator to shut down the session pool gracefully. The ID must be null for this release. This method is part of the administrative object library.

stopSessionPool

Synopsis

stopSessionPool(String id)

Parameters

id
Reserved for future use. Must be null.

Usage

Shut down a session pool; all active connections in the session are also terminated immediately. The ID must be null for this release. This method is part of the administrative class library.

removeSessionPool

Synopsis

removeSessionPool(String id)

Parameters

id
Reserved for future use. Must be null.

Usage

Shut down and remove the session pool; all active connections in this session pool are terminated immediately. The ID must be null for this release. This method is part of the administrative class library.

getSessionPool

Synopsis

SessionPool getSessionPool(String id)

Parameters

id
Reserved for future use. Must be null.

Usage

Get the session pool. If the session pool does not exist, this method will return nothing. The ID must be null for this release.

Returns

A session pool or nothing if it does not exist.

SessionPool Object

This object provides a SessionPool implementation for the Microsoft Active Server Pages environment. It is created by the createSessionPool method in the SessionPoolManager object.

SessionPool Methods

The SessionPool methods are used in conjunction with the SessionPool object:

call

Synopsis

Result call(String name, String indata[], Transaction tran)

Parameters

name
The name of a TUXEDO service.

indata
Array of name-value pairs or null for ASP built-in Request object.

tran
An optional Transaction object.

Usage

Call a service with a transaction (or null for no transaction). The indata is either a String array with name=value pairs or a null for an implicit ASP Request object. The name in the name=value pair should match the parameter name in the Jolt service definition. The member name in the Request object may have a trailing "_" and an index number (e.g., SBALANCE_0) if it is a multiple occurrence field. Any non-matching names in the indata parameter or Request object are ignored. The tran parameter must be the object returned by the startTransaction() method.

Returns

A Result object.

startTransaction

Synopsis

Transaction startTransaction(int timeout)

Parameters

timeout
The transaction time-out value in seconds.

Usage

Start a transaction. The transaction should be committed or aborted before continuing to another page, unless programmatic arrangements to commit or abort the transaction have been made. Otherwise, the connection is locked until the transaction is terminated.

Returns

A transaction object, or nothing if failure occurs.

getConnection()

Synopsis

Connection getConnection(int index)

Parameters

index
A connection index.

Usage

Get a connection. This method is part of the administrative API.

setMaxConnections

Synopsis

int setMaxConnections(int maxCons)

Parameters

maxCons
The new session pool size.

Usage

Change the session pool size. Currently shrinking the session pool is disallowed. This method is part of the administrative class library.

Returns

The new pool size.

getMaxConnections

Synopsis

int getMaxConnections()

Usage

Get the maximum number of connections configured in this session pool. This method is part of the administrative class library.

isSuspended

Synopsis

boolean isSuspended()

Usage

Check if this session pool is suspended, so it does not accept any new requests. This method is part of the administrative class library.

Template Object

This object provides the Template implementation for the Microsoft Application Server Pages. The output of the template content is sent to the web server response buffer.

BEAWEB.Template Component

The following component creates an instance of the Template object.

Synopsis

Server.CreateObject ("BEAWEB.Template")

Template Methods

The following methods are used in conjunction with the Template object:

eval - data set list

Synopsis

int eval(TemplateData data[])

Parameters

data
An array of TemplateData or Result objects.

Usage

Process the cached template with a list of data set and send the processed template to the response buffer. The list must be a VBScript Array object.

Results

0 if success; -1 for any error.

evalFile

Synopsis

int evalFile(String path, TemplateData data[])

Parameters

path
A path of the template file

data
An array of TemplateData or Result objects

Usage

Replace the tags in a template file with the values from a list of template data set. The list is an array object.

Returns

0 if success; -1 if the template file cannot be opened or there is an I/O error.

load

Synopsis

int load(String path)

Usage

Load the template from a file into memory for faster access. The contents are cached until the unload() is called.

Parameters

path
A path of the template file

Returns

0 if success, -1 if file cannot be opened.

unload

Synopsis

unload()

Usage

Unload the cached template.

TemplateData Object

This object represents the data set that can be used by template processing. It provides an extra method to import the ASP built-in Request object. The keys to the template data are the field names in the data set.

BEAWEB.TemplateData Component

The following component creates instances of the TemplateData object.

Synopsis

Server.CreateObject ("BEAWEB.TemplateData")

TemplateData Methods

The following methods are used in conjunction with the TemplateData object:

setValue

Synopsis

setValue(String name, String value)

Parameters

name
The name of the data element.

value
The string value for the data element.

Usage

This method is same as setValueByIndex(name,0,value) for non-octet value.

getValue

Synopsis

String getValue(String name, String defval)

Parameters

name
The name of the data element.

defval
The default string value for the data element, if it does not exist.

Usage

Get the string value of a data element associated with a name. Most output data, except carray (octets) data type, are automatically converted to String. If there is a type-cast error, the default value will be returned.

Returns

The string value of the data element or the default value.

setValueByIndex

Synopsis

setValueByIndex(String name, int index, String value)

Parameters

name
The name of the data element.

index
The index of the data element, starting from 0.

value
The string value for the data element.

Usage

Set the string value of a data element associated with a name and an index.

getValueByIndex

Synopsis

String getValueByIndex(String name, int index, String defval)

Parameters

name
The name of the data element

index
The index of the data element, starting from 0.

defval
The default value if the data element does not exist.

Usage

Get the string value of a data element associated with a name and an index. Most output data, except carray (octets) data type, are automatically converted to String. If there is a type-cast error, the default value will be returned.

Returns

The string value of the data element or the default value.

setBytesValue

Synopsis

setBytesValue(String name, byte value[])

Parameters

name
The name of the data element.

value
The byte value for the data element.

Usage

This method is same as setBytesByIndexValue(name,0,value) for the octet value.

getBytesValue

Synopsis

byte[] getBytesValue(String name, byte defval[])

Parameters

name
The name of the data element

defval
The default value if the data element does not exist.

Usage

Get the octet value of a data element associated with a name. If an output field has carray (octets) data type, the data remains as byte[]. The caller must use this method to retrieve the data. If there is a type-cast error, the default value will be returned.

Returns

The octet value of the data element or the default value.

getBytesValueByIndex

Synopsis

byte[] getBytesValueByIndex(String name, int index, byte defval[])

Parameters

name
The name of the data element

index
The index of the data element, starting from 0.

defval
The default value if the data element does not exist.

Usage

Get the octet value of a data element associated with a name and an index. If an output field has carray (octets) data type, the data remains as byte[]. The caller must use this method to retrieve the data. If there is a type-cast error, the default value will be returned.

Returns

The octet value of the data element or the default value.

setBytesValueByIndex

Synopsis

setBytesValueByIndex(String name, int index, byte value[])

Parameters

name
The name of the data element.

index
The index of the data element.

value
The byte value for the data element.

Usage

Set the octet value of a data element associated with a name and an index. The data element should be defined as carray in the TUXEDO application.

getCount

Synopsis

int getCount(String name)

Parameters

name
The name of the data element.

Usage

Get occurrence count of a data element.

Returns

The count of occurrences.

importRequest

Synopsis

void importRequest()

Usage

Import the values from the Microsoft ASP Request object into this TemplateData object.

Connection Object

This object represents a connection (TUXEDO session) to a Jolt server and provides simple methods for connection status. It is returned from the getConnection method on the SessionPool object. This object is a part of the administrative class library.

Connection Methods

The following methods are used in conjunction with the Connection object:

getAccessTime

Synopsis

Date getAccessTime()

Usage

Get the last access time of this object.

getAddr

Synopsis

String getAddr()

Usage

Get the server address.

getErrorCount

Synopsis

int getErrorCount()

Usage

Get the cumulative system error count.

getUseCount

Synopsis

int getUseCount()

Usage

Get the outstanding request count.

inTransaction

Synopsis

boolean inTransaction()

Usage

Check if the connection is in a transaction.

Returns

True if the connection is in a transaction; false otherwise.

isAlive

Synopsis

boolean isAlive()

Usage

Check if the connection is still alive.

Returns

True if the connection is still alive; false otherwise.

UserInfo Object

This object contains the TUXEDO user authentication information. This information may be needed to create a TUXEDO session.

BEAWEB.UserInfo Component

The following component creates an instance of the UserInfo object.

UserInfo

This component creates an instance of the UserInfo object.

Synopsis

Server.CreateObject ("BEAWEB.UserInfo")

UserInfo Methods

The following methods are used in conjunction with the UserInfo object:

setUserName

Synopsis

setUserName(String username)

Parameters

username
Specifies a valid user name.

Usage

You must set the TUXEDO user name before creating a session pool. This is only required if the user authorization level is specified in TUXEDO.

setUserPassword

Synopsis

setUserPassword(String password)

Parameters

password
A valid user password.

Usage

You must set the TUXEDO user password before creating a session. This is only required if the user authorization level is specified in TUXEDO.

setUserRole

Synopsis

setUserRole(String userrole)

Parameters

userrole
A valid user role.

Usage

You must set the TUXEDO user role before creating a session. This is only required if the user authorization level is specified in TUXEDO.

setAppPassword

Synopsis

setAppPassword(String password)

Parameters

password
A valid application password.

Usage

You must set the TUXEDO application password before creating a session. This is only required if the application or user authorization level is specified in TUXEDO.

Transaction Object

This object is a wrapper for the bea.jolt.JoltTransaction object. If an error occurs, the method in this object returns an error code instead of throwing an exception. This object is returned by the startTransaction method or the SessionPool object.

Transaction Methods

The following methods are used in conjunction with the Transaction object:

commit

Synopsis

int commit()

Usage

Commit the transaction.

Returns

0 if successful; otherwise, a TUXEDO error number.

rollback

Synopsis

int rollback()

Usage

Roll back the transaction.

Returns

0 if successful; otherwise, a TUXEDO error number.

Result Object

This object represents the result set from the service invocation. Most output data types are converted into String, except carray which remains as byte[]. The caller must use the getBytesValue() methods to get the carray data. The keys the data in the Result object are the field names in the result set. Since this object is derived from the TemplateData object, it can be used by the Template object for template processing. This object is returned from the call() method or the SessionPool object.

Result Methods

The following methods are used in conjunction with the Result object:

applicationError

Synopsis

boolean applicationError()

Usage

Test if an application error occurred in the corresponding service invocation. The application error is equivalent to TPESVCFAIL in TUXEDO.

Returns

True if an application error occurs.

systemError

Synopsis

boolean systemError()

Usage

Test if a system error occurred in the corresponding service invocation.

Returns

True if a system error occurs.

getError

Synopsis

int getError()

Usage

Get the system (non-TPESVCFAIL) error number. The error number is same as the tperrno in TUXEDO.

Returns

The system error number.

getErrorDetail

Synopsis

int getErrorDetail()

Usage

Get the detail system error number. This information is available only to TUXEDO 6.4 and then only if the service call has timed out.

Returns

The detail system error number or 0.

getApplicationCode

Synopsis

int getApplicationCode()

Usage

Get the application code returned by the service. The application code is same as the tpurcode in TUXEDO.

Returns

The application code.

getStringError

Synopsis

String getStringError()

Usage

Get the system error message. If it is not a system error, null is returned.

Returns

The system error message.

getStringErrorDetail

Synopsis

String getStringErrorDetail()

Usage

Get the detail system error message. This information is available only to
TUXEDO 6.4 and then only if the service call has timed out.

Returns

The detail system error message or null.

noError

Synopsis

boolean noError()

Usage

Test if no error was encountered in the corresponding service invocation.

Returns

True if there is no error.

setValue

Synopsis

setValue(String name, String value)

Parameters

name
The name of the data element.

value
The string value for the data element.

Usage

This method is same as setValueByIndex(name,0,value) for non-octet value.

getValue

Synopsis

String getValue(String name, String defval)

Parameters

name
The name of the data element.

defval
The default string value for the data element, if it does not exist.

Usage

Get the string value of a data element associated with a name. Most output data, except carray (octets) data type, are automatically converted to String. If there is a type-cast error, the default value will be returned.

Returns

The string value of the data element or the default value.

setValueByIndex

Synopsis

setValueByIndex(String name, int index, String value)

Parameters

name
The name of the data element.

index
The index of the data element, starting from 0.

value
The string value for the data element.

Usage

Set the string value of a data element associated with a name and an index.

getValueByIndex

Synopsis

String getValueByIndex(String name, int index, String defval)

Parameters

name
The name of the data element

index
The index of the data element, starting from 0.

defval
The default value if the data element does not exist.

Usage

Get the string value of a data element associated with a name and an index. Most output data, except carray (octets) data type, are automatically converted to String. If there is a type-cast error, the default value will be returned.

Returns

The string value of the data element or the default value.

setBytesValue

Synopsis

setBytesValue(String name, byte value[])

Parameters

name
The name of the data element.

value
The byte value for the data element.

Usage

This method is same as setBytesByIndexValue(name,0,value) for the octet value.

getBytesValue

Synopsis

byte[] getBytesValue(String name, byte defval[])

Parameters

name
The name of the data element

defval
The default value if the data element does not exist.

Usage

Get the octet value of a data element associated with a name. If an output field has carray (octets) data type, the data remains as byte[]. The caller must use this method to retrieve the data. If there is a type-cast error, the default value will be returned.

Returns

The octet value of the data element or the default value.

getBytesValueByIndex

Synopsis

byte[] getBytesValueByIndex(String name, int index, byte defval[])

Parameters

name
The name of the data element

index
The index of the data element, starting from 0.

defval
The default value if the data element does not exist.

Usage

Get the octet value of a data element associated with a name and an index. If an output field has carray (octets) data type, the data remains as byte[]. The caller must use this method to retrieve the data. If there is a type-cast error, the default value will be returned.

Returns

The octet value of the data element or the default value.

setBytesValueByIndex

Synopsis

setBytesValueByIndex(String name, int index, byte value[])

Parameters

name
The name of the data element.

index
The index of the data element.

value
The byte value for the data element.

Usage

Set the octet value of a data element associated with a name and an index. The data element should be defined as carray in the TUXEDO application.

getCount

Synopsis

int getCount(String name)

Parameters

name
The name of the data element.

Usage

Get occurrence count of a data element.

Returns

The count of occurrences.

importRequest

Synopsis

void importRequest()

Usage

Import the values from the Microsoft ASP Request object into this TemplateData object.