Creating an HTML CORBA client application

Distributed application development is a feature of JBuilder Enterprise.

HTML client applications are HTML forms connected to CORBA objects. The mechanism that is used to link the controls to CORBA objects is the <SERVLET> tag. When the <FORM> is rendered, the servlet tag is placed at the end of each form. The object invoked by this servlet tag is the gateway object. Servlets are modules that run inside of servlet-enabled Web servers, extending their functionality. When you request client-side navigation buttons as part of the client layout, the servlet tag generates JavaScript that appears on the client HTML page. The HTML browser must be at least Internet Explorer 4.0 or Netscape 4.0 or higher when JavaScript is used. For more information on servlets, see the "Developing servlets" chapter.


Tutorial: creating an HTML client application from IDL

These steps assume you want to create a new HTML client application from an IDL file.

To create an HTML client from an IDL file,

  1. Create the IDL file
  2. Generate the client
  3. Compile the project
  4. Test and deploy the application
More detailed information on each step is provided in the following sections.

Creating the IDL file

To create the IDL file, first, create a new project.

  1. Select File|New Project from the JBuilder menu.
  2. Enter the Project Name and Project Directory Name. For this example, I used Bank Tutorial for both.
  3. Click Next. Click Add in the Required Library box.
  4. Add the VisiBroker library. (If it is not already set up, run Tools|Enterprise Setup as described in "Setting up JBuilder for CORBA applications.")
  5. Click Next.
  6. Optionally, enter the Title, Author, Company, and Description fields.
  7. Click Finish.

To create and enter the code for the IDL file,

  1. Select File|New, then select Sample IDL from the Enterprise tab of the Object Gallery.
  2. Type BankTutorial.IDL in the File Name field. Click OK. A sample IDL file is created and added to the project.
  3. Remove the sample code, and add your desired IDL code to this file by typing it directly into the Source pane. For more information on writing IDL code, point your browser to http://cgi.omg.org/library/corbidl.html to download information about IDL syntax and semantics. The following example IDL code is also used in the introductory CORBA tutorial, "Exploring CORBA-based distributed applications in JBuilder".


    module BankTutorial {
        interface Account {
            float balance();
        };
        interface AccountManager {
            Account open(in string name);
        };
    };
    

  4. Select File|Save All. The IDL file must be saved before it will compile.

To compile the BankTutorial.idl file,

  1. Right-click on the BankTutorial.idl file in the project pane.
  2. Select Make.

Generating the client

From the compiled IDL file, JBuilder can generate multi-tier CORBA applications with the HTML CORBA Client wizard. The following steps show how to generate an HTML client application in this way.
  1. Select File|New, then select HTML CORBA Client from the Enterprise page of the Object Gallery.
  2. Select the correct IDL file and package. If only one IDL file exists in the project, this information should be correct.
  3. Click OK.

Two files are generated by the wizard. If the BankTutorial.idl file is used, as in this example, the files are:

By default, the HTML client can do the following:

The JSP file does this by placing PARAM tags within the SERVLET tag. Some HTML editing tools remove PARAM tags from within a SERVLET tag. To prevent this from happening, the SERVLET tag is bracketed by comment tags that are understood by the editing tools.

Compiling your project

Once you've generated the files for your distributed application, you're ready to compile and run it for the first time. To compile your project,

  1. Select Project|Rebuild Project.


Running the HTML client application

The following sections discuss testing the HTML client using the JSP that was generated by the application. The general steps for running this application are

  1. Right-click on the JSP file.
  2. Select Web Run.

The Web View page of the content pane displays the JSP. For local testing, the URL points to localhost:8080, which is where Tomcat is running. The output/log data from Tomcat will appear on a new tab in the Message pane. Output from servlets or beans, as well as HTTP commands and parameter values, are echoed to this pane. Run-time properties of the Web server may be set by selecting Project|Project Properties, and selecting JSP/Servlet on the Run tab. The port number is the port on which the Web server will run. The default is 8080. If port 8080 is in use, by default JBuilder will search for an unused port.

Deploying the client files (production environment)

For development purposes JBuilder uses the Tomcat Web server to execute the JSP. For deployment onto a production Web server, consult the documentation for that Web server for information on how to deploy HTML client applications to it.

Once you have deployed your application, you can run the client and server on either the same machine or on different machines in the same subnet.