![]() |
![]() |
![]() |
![]() |
![]() |
There are two parts to the simpapp example for Jolt for WebLogic Server:
• The HTTP servlet that is shipped with the examples that are installed in the samples directory where Oracle Tuxedo is installed.
• The Tuxedo service application that is shipped with the Tuxedo examples that are installed with Oracle Tuxedo. The Tuxedo simpapp server contains the TOUPPER service, which converts a given string to uppercase.The source code for the Jolt servlet simpapp example is located in the /samples/jolt/wls/servlet/ directory in the Tuxedo distribution.The simpapp sample directory contains the following files:
A complete listing of the Tuxedo server-side source code of the simpapp application service is located in $TUXDIR/samples/atmi/simpapp on UNIX systems and in %TUXDIR%\samples\atmi\simpapp on Windows 2003 systems (where TUXDIR is the Tuxedo home directory).
• The Oracle Tuxedo architecture and the simpapp application
• The simpapp example is easy to follow. Just launch the simpapp.html page from the WebLogic Server. The simpapp.html page loads an HTML form which contains a text field for entering the string. Type in a string and click the Post button to submit the string as a post request. The SimpAppServlet formats the string you typed for use with the Jolt for WebLogic class libraries, and then dispatches the request to the Tuxedo TOUPPER service, which transposes the string to uppercase and returns it for display in the browser.Configuring the simpapp servlet example requires the following steps:
3. Configure and boot Tuxedo and the simpapp example.
4. Follow the directions in the Tuxedo user documentation to bring up the server-side simpapp application. Make sure the TOUPPER service is available.
5. Set up the Jolt Server. Refer to the Using Oracle Jolt for information about how to configure a Jolt Server.
• Use the Jolt BulkLoader file to ensure that the TOUPPER service is defined in the Metadata Repository.The simpapp example directory has a simpapp.rep file that contains the TOUPPER service definition. Your system administrator should use the BulkLoader to add this service definition to the existing Metadata Repository on the Tuxedo server. Refer to Using Oracle Jolt for details.On the Tuxedo server, the following code example uses the Jolt BulkLoader to add the TOUPPER service definition:where host and port are the hostname and port number of your Jolt Server Listener (JSL), and the simpapp.rep is the BulkLoader file provided by Oracle Jolt, located in one of the following locations:%TUXDIR%\samples\jolt\wls\servlet\ on Windows 2003
6. Confirm that you have properly set up your CLASSPATH during installation. The WebLogic Server classes library contains the three .jar files that you will need to run this example:
• If you are using a Windows 2003 system, you can start the WebLogic Server from the Start menu. Otherwise, use the startWebLogic script on the command line, in the root directory of the WebLogic Server distribution.For more information on starting the WebLogic Server, see “Starting and Stopping the WebLogic Server” in the Oracle WebLogic Server Administration Guide.
1. Copy the simpapp.html page into your WebLogic document root directory.By default, this is the \config\mydomain\applications\simpapp directory in your WebLogic Server distribution. The HTTP server built into WebLogic looks in this directory for HTML pages and other MIME types.
2.
c. For the Class Name, enter the following name: bea.jolt.pool.servlet.weblogic.PoolManagerStartUp
There are no arguments for this startup class.
10. Register the simpapp servlet as a Web application, as follows:
b.
c. For Step 1, either accept the default a destination directory for the simpapp servlet or select a different one.
d. For Step 2, enter the path to the simpapp servlet (or use the Browse feature), and then click the Upload button.The simpapp servlet is registered as a Web application in WebLogic and appears as an icon under the Deployments\Web Applications folder.In order to start the Jolt session pool, you must shut down the WebLogic Server, and then restart it. For more information on restarting the WebLogic Server, see “Starting and Stopping the WebLogic Server” in the Oracle WebLogic Server Administration Guide.After restarting the WebLogic Server, compile the SimpAppServlet file, as follows:
1. Under your WebLogic \config\mydomain\applications\simpapp document root directory, create a new WEB-INF directory.
2. Copy the web.xml file from the Tuxedo installation directory \samples\jolt\wls\servlet\ into the new WEB-INF directory.
3. Compile the SimpAppServlet.java file, as follows:This step also copies the necessary java classes into a WEB-INF\classes directory.
2. Enter the URL for the simpapp.html file. For example, the default URL is:http://localhost:port/simpapp/simpapp.htmlwhere localhost is the host name of the WebLogic Server, and port is the port at which the WebLogic Server is listening for login requests.A page similar to the one shown in Figure B‑1 is displayed:Figure B‑1 simpapp.html ExampleIf you have problems displaying the form, be sure that the simpapp.html file is in the WebLogic document root.Enter some text into the text field on the HTML page and submit it by clicking the POST button. Along with the text you entered, other parameters are submitted to the simpapp servlet class running in WebLogic Server.The following is the relevant section from the simpapp.html file that describes the HTML form:When the WebLogic Server receives the HTTP form request, it invokes the doPost() method of the simpapp servlet and passes the form data into an HttpServletRequest.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: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.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: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: The TOUPPER 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.The final step constructs and sends an HTML page, which contains the results of the service call, back to the client through the HttpResponse output stream. The uppercase result is retrieved from the ServletResult object using the result.getValue() method.Figure B‑2 Output Stream Results Example