Step 8. Process the Request
Before the first request to the simpapp
servlet, WebLogic initializes the
servlet by calling its init()
method. The Jolt session pool is established in
the following manner:
ServletSessionPoolManager b_mgr =
(ServletSessionPoolManager).SessionPoolManager.poolmanager;
Next, the servlet’s doPost()
method is executed. This method contains the
code to get a connection from the simpapp
session pool that was created
during the startup of the WebLogic Server. The following code snippet shows the code that is
used to retrieve the simpapp
session pool.
// Get the "simpapp" session pool
ServletSessionPool session =
(ServletSessionPool) b_mgr.getSessionPool("simpapp");
The Tuxedo service that will be called is identified in a hidden field, which is retrievable from the request object. Retrieve the service name parameter as follows:
String svcnm[] = req.getParameterValues("SVCNAME");
You retrieve the value of the SVCNAME
field in a string array that contains
a single value; use only the first element of the array. The value set for the
SVCNAME
hidden field in the form is TOUPPER
. This is the
name of the Tuxedo service that the servlet invokes, which is passed to the
call()
method as follows:
// Invoke a service and get the result.
result = session.call(svcnm[0], req);
The session
object in this example is a ServletSessionPool
that can accept the HttpServletRequest
object directly. Internally, it
converts the data into a Jolt DataSet object, which contains the parameters for the
TOUPPER
service.
Note:
TheTOUPPER
service expects a case-sensitive parameter called "STRING"
, so it is essential for the text field within the HTML form to be labeled exactly the same, that is, "STRING"
. Note also that the other data fields, such as the SVCNAME,
are not relevant as parameters but don't disrupt the Tuxedo service.
The form parameter is used to actually name the service, which you don't have to pass as a
service parameter. It is passed automatically because it is already contained in the
HttpServletRequest
object.
The TOUPPER
service converts the text in the "STRING"
parameter to uppercase text and passes it back to the servlet in a ServletResult
object that contains the results of an executed call, as well as details about exceptions if any are thrown during the service call.
Parent topic: Using the Example