|
| WebLogic Server 6.0 Code Examples, BEA Systems, Inc. |
Package examples.wlec.servlets.simpapp
This example demonstrates how to use WebLogic Enterprise Connectivity to
access a WebLogic Enterprise CORBA object from a servlet on WebLogic Server.
See:
Description
Class Summary |
SimpappServlet |
This example demonstrates how a WebLogic Servlet can connect to WebLogic Enterprise
and invoke an operation on a CORBA object. |
Package examples.wlec.servlets.simpapp Description
This example demonstrates how to use WebLogic Enterprise Connectivity to
access a WebLogic Enterprise CORBA object from a servlet on WebLogic Server. The example combines a WLS servlet and the WLE Simpapp example.
The following figure illustrates the WLEC Servlet Simpapp example.
When you run the WLEC Servlet Simpapp example, the following events occur:
- At startup:
- WLS creates a WLEC Internet Inter-ORB Protocol (IIOP) connection pool for the WLE Simpapp domain.
- The Simpapp Servlet init
method obtains a connection from the IIOP connection pool.
The remaining steps are performed at run time.
- The form-based Internet client sends a request, including an input string, to the servlet.
- Acting as a WLE client, the servlet service method:
- Activates the connection to the Simpapp domain.
- Invokes the desired operation on the Simple CORBA object with the
data that it received from the Internet client.
- The Simple object performs the specified operation and returns
the results to the Simpapp servlet. The Simple object can perform two operations:
- Accept a string and return the string in uppercase.
- Accept a string and return the string in lowercase.
- The Simpapp servlet compiles the results into a dynamically-generated
HTML page and sends the page to the Internet client.
The following section describes how to build and run the example:
- Prerequisites
- Build the Example
- Configure the Server
- Run the Example
Install and set up the following:
- WebLogic Server (WLS)
- Java Development Kit (JDK)
- WebLogic Enterprise (WLE
See Platform Support for WebLogic Enterprise Connectivity for information about the supported versions for each product.
- Build and run the WLE Simpapp sample.
See the Java Simpapp Sample Application in the WLE documentation:
- Go to J2EE Topics on the Web.
- Scroll down and click Sample Applications.
- Click Java Simpapp Sample Application.
The build procedure for the Java version of the Simpapp
sample generates the client stubs and puts them in your working
directory. Client stubs provide the programming interface for CORBA
object operations.
- Set up your WLS development shell as described in
Setting up your environment for building and running the examples.
- Modify classpaths:
- Add %WL_HOME%\lib\wleorb.jar to CLASSPATH in %WL_HOME%\config\examples\setExamplesEnv.cmd (NT) or $WL_HOME/config/examples/setExamplesEnv.sh (UNIX).
- Add %WL_HOME%\lib\wleorb.jar (NT) or $WL_HOME/lib/wleorb.jar (UNIX) to CLASSPATH in the start script.
If you are going to start WLS by running startExamplesServer, set CLASSPATH in the startExamplesServer.cmd file (NT) or the startExamplesServer.sh file (UNIX). Otherwise, set CLASSPATH by means of another method such as the command line or the NT System Properties dialog box.
Note: You need to add RemoteObjectReference class to your classpath in start script. This class is bundled under wlej2eecl.jar file in WLE 5.1 and under m3.jar file in WLE 5.0.
%TUXDIR%\udataobj\java\jdk\wlej2eecl.jar
where:
- %TUXDIR%
- Your WLE installation directory.
For information about setting CLASSPATH for WLS, see Setting up your environment for building and running the examples.
- Copy the compiled WLE Simpapp client stubs to your WLS SERVER_CLASSES directory, where SERVER_CLASSES is an environment variable that you set when you set up your development environment. The files you need to copy are:
- Simple.class
- SimpleFactory.class
- SimpleHelper.class
- SimpleFactoryHelper.class
- _SimpleStub.class
- _SimpleFactoryStub.class
- Compile SimpappServlet.java
with one of the following commands.
On Windows NT:
javac -d %EX_WEBAPP_CLASSES% SimpappServlet.java
On UNIX:
javac -d $EX_WEBAPP_CLASSES SimpappServlet.java
- Copy the file Simpapp.html
located in the samples/examples/wlec/servlets/simpapp directory in your WebLogic Server installation
to the config/examples/applications/examplesWebApp directory in your WebLogic Server installation.
This directory is the location of the publically-available files of the examplesWebApp.
Configure the Server
- Initialize an IIOP connection pool:
- Start the server with the examples
configuration in a new command shell.
- Bring up the Administration Console in your browser.
- Click to expand the Services node in the left-hand pane.
- Click to expand the WLEC node in the left-hand pane.
- Select the simplepool node.
- Select the Configuration tab in the right-hand pane to display the General and Security tab.
- Select the General tab to display the Primary and Failover addresses.
- Change the Primary Addresses and Failover Addresses from [//wlehost:2468] to [//host:port].
where:
- host
- The name of the local machine.
- port
- The TCP port number at which the ISL process listens for incoming requests; it must be a number between 0 and 65535. The default value is 2468.
- Note: If you are running the example on UNIX change the Domain from [simple] to [simpapp].
NT user can leave the Domain to the default Domain id [simple].
- Click the Apply button to save the assignment.
-
Select the Targets tab in the right-hand pane to display the Available and Chosen
targets.
-
Move the examplesServer from the Target column to the Chosen column and click the Apply button to
save the assignment.
- Make sure that the examplesWebApp is deployed on your server.
Run the Example
- Start a web browser and enter the URL for Simpapp.html.
For example:
http://localhost:7001/examplesWebApp/Simpapp.html
- On the HTML form:
- Enter some text in either uppercase or lowercase.
- Select the operation. (TO UPPER or TO LOWER)
- Click GO.
- Watch for the results. An uppercase string will convert to lowercase and vice versa.
There's More...
Read more about:
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.