    All Examples  All WebLogic Enterprise Connectivity Examples

# package examples.wlec.servlets.university

## WebLogic Enterprise Connectivity servlet university example

##

- UniversityHelper

# About this example

This example demonstrates how to use WebLogic Enterprise Connectivity to access a WebLogic Enterprise CORBA object from a servlet on WebLogic Server. The example uses WebLogic JSP and the WebLogic JSPServlet.

1. At startup:
   - WebLogic Server creates a connection pool for the University domain.
   - The University servlet's init method obtains a connection from the connection pool.

   The remaining steps are performed at run time.

2. The HTML client sends a request and input string to a JSP:
   - Before sending the request, the HTML client might use an additional HTML file to request and retrieve input data.
   - The JSPServlet finds the JSP file and uses the JSP compiler to compile the JSP file into a servlet class. (For more information about JSP and the JSPServlet, see Using WebLogic JSP.)

3. Acting as a WebLogic Enterprise client, the JSP:
   - Activates the connection to the University domain.
   - Invokes the desired operation on the University object with the data that it received from the HTML client.

4. The University object performs the specified operation and returns the results to the JSP. The University object can perform the following operations:
   - Display a list of all the courses.
   - Display a list of courses based on a search string.
   - Display information about a course.
   - Register a student for a course.
   - Display a list of registered courses for a student.

5. The JSPServlet compiles the results into a dynamically generated HTML page and sends the page to the HTML client.

# How to use this example

## Prerequisites

Install and set up WebLogic Server, JDK, and WebLogic Enterprise. See Platform Support for WebLogic Enterprise Connectivity for information about the supported versions for each of these products.

## Setting up the example

1. Build and run the WebLogic Enterprise University Transactions sample.

   See the University Transactions Sample Application in the WebLogic Enterprise documentation. If you are viewing this document on the Web, see the WebLogic Enterprise documentation on the Web. If you are viewing this document from the documentation CD, see the WebLogic Enterprise documentation on the CD. To get to the University Transactions Sample Application, click CORBA Topics, scroll down and click Sample Applications, then click Transaction Sample under Overview of University Sample Applications.

   The build procedure for the Java version of the example generates the client stubs and puts them in your working directory. Client stubs provide the programming interface for CORBA object operations.

   You can use the C++ version of the example, which uses C++ client stubs instead of Java client stubs. If you use the C++ version, you must run the idltojava compiler on the simple.idl file to generate Java client stubs.

   For information about manually generating client stubs, see Creating CORBA Client Applications in the WebLogic Enterprise documentation. If you are viewing this document on the Web, see the WebLogic Enterprise documentation on the Web. If you are viewing this document from the documentation CD, see the WebLogic Enterprise documentation on the CD. To get to Creating CORBA Client Applications, click CORBA Topics, then scroll down and click Creating CORBA Client Applications.

   WebLogic Enterprise provides the idltojava compiler. You must run the idltojava compiler on a computer with a C++ development environment, because it runs the C precompiler on the .idl source.

2. Set up your WebLogic Server development environment as described in Setting your development environment.

3. Copy the compiled WebLogic Enterprise Transactions University client stubs to your WebLogic Server SERVER_CLASSES directory, with one of the following commands.

   On Windows NT:

           COPY univ_dir\transactions\UniversityT\*.class %SERVER_CLASSES%

   On UNIX:

           cp univ_dir/transactions/UniversityT/*.class $SERVER_CLASSES$

   where univ_dir is the location of the WebLogic Enterprise University sample.

4. Compile UniversityHelper.java with one of the following commands.

   On Windows NT:

           javac -d %SERVLET_CLASSES% *.java

   On UNIX:

           javac -d $SERVLET_CLASSES$ *.java

5. Copy the .html files into your registered document root, which defaults to myserver/public_html.

6. Initialize an IIOP connection pool by modifying the weblogic.properties file.

   You can uncomment and edit the weblogic.CORBA.connectionPool.Univpool property in the weblogic.properties file. See the Administrators Guide Setting up WebLogic Enterprise Connectivity.

## Running the example

1. If you are using Java 2, Version 1.2, make sure that the Java system classpath in your server shell includes ./lib/poolorb.jar.

   Add this .jar file to the JAVACLASSPATH environment variable in the startWebLogic.cmd file (NT) or the startWebLogic.sh file (UNIX).

2. Start WebLogic Server in your server shell.

3. Start a Web browser and enter the URL for UniversityForm.html. For example:

   http://localhost:7001/UniversityForm.html

4. On the HTML form:

   - Choose an operation.
   - Fill in the form.
   - Submit the form.

5. Watch for the results. The results depend on the operation you chose.

# There's more...

Read more about configuring and using WebLogic Enterprise Connectivity in:

- Administrators Guide Setting up Weblogic Enterprise Connectivity
- Developers Guide Using WebLogic Enterprise Connectivity

Copyright © 2000 BEA Systems, Inc. All rights reserved.
Last updated 3/8/00