|
|
Using Servlet Connectivity for Tuxedo
With BEA Jolt servlet connectivity, you can use HTTP servlets to perform server-side Java tasks in response to HTTP requests. Jolt certifies servlet connectivity with the Java Web Server versions 1.1.3 and up, and supports most other standard servlet engines. Using the Jolt session pool classes, a simple HTML client can connect to any Web server that supports generic servlets. Thus, all Jolt transactions are handled by a servlet on the web server rather than being handled by a client applet or application.
This capability means that HTML clients can invoke Tuxedo services without directly connecting to Tuxedo. HTML clients can instead connect to a Web server, through HTTP, where the Tuxedo service request is executed by a generic servlet. Using a Jolt session, the servlet on the web server administers the Tuxedo service request by connecting to the Tuxedo Server through the Jolt Server Handler (JSH) or the Jolt Server Listener (JSL), which then makes the Tuxedo service request. This capability allows many types of HTML clients to make remote Tuxedo service requests. All Jolt transactions are handled on the server side without requiring any change to the original HTML client. Thus, HTML clients are allowed to be very simple and require little maintenance.
This section covers the following topics:
A servlet is any Java class that can be invoked and executed on a server, usually on behalf of a client. A servlet works on the server, while an applet works on the client. An HTTP servlet is a Java class that handles an HTTP request and delivers an HTTP response. HTTP servlets reside on an HTTP server and must extend the JavaSoft javax.servlet.http.Http Servlet Class so that they may run in a generic servlet engine framework.
Some advantages of using HTTP servlets are:
With Jolt servlet connectivity, any generic HTTP servlet allows you to take advantage of the Jolt features. Jolt servlets handle HTTP requests using the following Jolt classes:
The Jolt Servlet Connectivity Classes
Following are descriptions of the Jolt servlet connectivity classes:
ServletDataSet
This class contains data elements that represent the input and output parameters of a BEA Tuxedo service. It provides a method to import the HTML field names and values from a javax.servlet.http.HttpServletRequest object.
ServletPoolManagerConfig
This class is the startup class for a Jolt Session Pool Manager and one or more associated Jolt Session Pools. It creates the session pool manager if needed and starts a session pool with a minimum number of sessions. Jolt Session Pool Manager that internally keeps track of one or more named session pools.
This class is derived from bea.jolt.pool.PoolManagerConfig and allows the caller to pass a Properties or Hashtable object to the static startup() method to create a session pool and the static getSessionPoolManager() method to get the session pool manager of bea.jolt.pool.servlet.ServletSessionPoolManager class.
ServletResult
This class provides methods to retrieve each field in a ServletResult object as a String.
ServletSessionPool
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.
ServletSessionPoolManager
This class is a servlet-specific session pool manager. It manages a collection of one or more session pools of class ServletSessionPool . This class provides methods that are used to create both the ServletSessionPoolManager itself and the session pools that it contains. These methods are part of the administrative API for a session pool.
Writing and Registering HTTP Servlets
You must first import the packages that support Jolt servlet connectivity (jolt.jar , joltjse.jar , servlet.jar ). HTTP servlets must extend javax.servlet.http.HttpServlet. After you write your HTTP servlets, you register them with a Web server that supports generic servlets. Your custom servlets are treated exactly like the standard HTTP servlets that provide the HTTP capabilities.
Each HTTP servlet is registered against a specific URL pattern, so that when a matching URL is requested, the corresponding servlet is called upon to handle the request.
Refer to the documentation for your particular Web server for instructions on how to register servlets.
Jolt Servlet Connectivity Sample
The Jolt software includes three sample applications that demonstrate servlet connectivity using the Jolt servlet classes. The three samples are:
Refer to these samples in to see code examples of how to use the Jolt servlet classes in your own servlets.
Viewing the Sample Servlet Applications
To view the code for the Jolt sample applications, you need to install the Jolt API client classes (usually chosen as an option when installing Jolt). Once the classes are installed in your directory of choice, navigate to the following directory to see the sample application files:
<Installation directory>\udataobj\jolt\examples\servlet
To view the sample code, use a text editor such as Microsoft NotePad to open the Java files for each sample application.
SimpApp Sample
A sample application named "Simpapp" is included with Jolt. The Simpapp application illustrates how the servlet uses Servlet Connectivity for Tuxedo. The following servlet tasks are illustrated by the Simpapp sample:
This example demonstrates how a servlet may connect to Tuxedo and call upon one of its services; it should be invoked from the simpapp.html file. The servlet creates a session pool manager at initialization, which is used to obtain a session when the doPost() method is invoked. This session is used to connect to a service in Tuxedo with a name described by the posted "SVCNAME " argument. In this example the service is called "TOUPPER ", which transposes the posted "STRING " argument text into uppercase, and returns the result to the client browser within some generated HTML.
Note: The WebLogic Server is used in this example.
Requirements for Running the Simpapp Sample
The requirements for Running the Simpapp sample are:
javac -classpath $(JAVA_HOME)/lib/classes.zip:$(JSDK)/lib/servlet.jar:
$(JOLTHOME)/jolt.jar:$(JOLTHOME)/joltjse.jar:./classes
-d ./classes SimpAppServlet.java
Note: The package name of the SimpAppServlet is "examples.jolt.servlet.simpapp."
#simpapp
#Fri Apr 16 00:43:30 PDT 1999
poolname=simpapp
appaddrlist=//host:7000,//host:8000
failoverlist=//backup:9000
minpoolsize=1
maxpoolsize=3
userrole=tester
apppassword=appPass
username=guest
userpassword=myPass
weblogic.httpd.register.simpapp=examples.jolt.servlet.SimpAppServlet
http://mywebserver:8080/simpapp.html
BankApp Sample
The "Bankapp" application illustrates how the servlet is written with PageCompiledServlet with Servlet Connectivity for Tuxedo. Bankapp illustrates the following:
Requirements for Running the Bankapp Sample
Following are the requirements for running the Bankapp sample:
bankapp.properties
tellerForm.html
inquiryForm.html
depositForm.html
withdrawalForm.html
transferForm.html
InquiryServlet.jhtml
DepositServlet.jhtml
WithdrawalServlet.jhtml
TransferServlet.jhtml
#bankapp
#Fri Apr 16 00:43:30 PDT 1999
poolname=bankapp
appaddrlist=//host:8000,//host:7000
failoverlist=//backup:9000
minpoolsize=2
maxpoolsize=10
userrole=teller
apppassword=appPass
username=JaneDoe
userpassword=myPass
http://mywebserver:8080/tellerForm.html
Admin Sample
The "Admin" sample application illustrates the following servlet tasks:
Requirements for Running the Admin Sample
Following are the requirements for running the Admin sample:
1. Install the Jolt class library and Servlet Connectivity for Tuxedo class library to the web application server.
2. Copy all JHTML files to the public HTML directory (for example, $WEBLOGIC/myserver/public_html for WebLogic ):
PoolList.jhtml
PoolAdmin.jhtml
3. To get a list of session pools, use the following URL in your favorite browser:
http://mywebserver:8080/PoolList.jhtml
Additional Information on Servlets
For more information on writing and using servlets, see the following sites:
BEA WebLogic Servlet Documentation
http://www.weblogic.com/docs/classdocs/API_servlet.html
Java Servlets
http://jserv.java.sun.com/products/java-server/documentation/
webserver1.1/index_developer.html
Servlet Interest Group
servlet-interest@java.sun.com
|
Copyright © 1999 BEA Systems, Inc. All rights reserved.
|