Preparing for the company intranet sample application

System prerequisites

The hardware and operating system prerequisites for building and running the YourCompany sample application are the same as those that are specified for the IBM Rational Developer product. This scenario was originally developed for IBM Rational Application Developer. The instructions provided here should work for other IBM Rational Developer product configurations that include Page Designer and the other Web development tools.

In addition to IBM Rational Developer and its prerequisites, you need a back-end database installed in order to build and test the dynamic Web pages of the Your Company sample application. You can use one of the following databases:

You will need to install WebLogic Server 6.1 SP7, 7.0 SP5, or 8.1 SP3 as your application server.

Enabling JDBC(TM) 2.0 on DB2

Note: You only need to enable JDBC 2.0 if you want to explore the database features of the YourCompanyExample project and if you are using DB2 version 7.2 as your back-end database.

JDBC 2.0 allows Java applications to access relational and nonrelational database management systems. To ensure that JDBC 2.0 is enabled on DB2:

For Windows

  1. Open a DB2 command window (Start > Programs > IBM DB2 > Command Line Tools > Command Window), then navigate to DB2_INSTALL_PATH\SQLLIB\java12, where DB2_INSTALL_PATH is the path where you installed DB2.
  2. Stop all DB2 services and make a note of the services you stopped.
  3. Run the following command to change your database installation to use JDBC 2.0: usejdbc2.bat (If you are denied access when running the usejdbc2 batch file, you have not stopped all of the DB2 processes.)
  4. Restart the services that you stopped.

To ensure that the essential DB2 processes are running, issue the following command in a DB2 command window: db2start

For Linux Note: The Linux instructions in this scenario assume that you have installed DB2 in the default location and accepted the default user ID. To enable the JDBC 2.0 driver and create the database:

  1. Ensure that you are logged on as user db2inst1.
  2. Navigate to the following directory: /home/db2inst1
  3. Edit the file .bashrc and add the following lines of code to the bottom of the file:
    if [ -f /home/db2inst1/sqllib/java12/usejdbc2 ]; then    
       . /home/db2inst1/sqllib/java12/usejdbc2 
    fi  
    
  4. Save and close the file.
  5. Issue the following command: source ./.bashrc
  6. Exit from user db2inst1.
  7. To ensure that the correct database libraries are accessed, complete the following steps:
    1. Navigate to the home directory.
    2. Edit the file .bashrc and add the following lines of code to the bottom of the file:
      if [ -f /home/db2inst1/sqllib/db2profile ]; then
          . /home/db2inst1/sqllib/db2profile 
      fi         
      if [ -f /home/db2inst1/sqllib/java12/usejdbc2 ]; then
          . /home/db2inst1/sqllib/java12/usejdbc2 
      fi 
      
    3. Save and close the file.
    4. Issue the following command from the home directory: source ./.bashrc
  8. Exit from IBM Rational Developer and then open IBM Rational Developer again to pick up the environment changes.

Setting up the development and run-time environments

Once IBM Rational Deployment Toolkit for WebLogic Server has been installed, it is necessary to configure a server preference in IBM Rational Developer to give the toolkit access to server resources.

  1. From the menu, go to Window > Preferences.
  2. Select Server in the left pane. The Server page opens.
  3. Check Create server resources in workspace and click OK.

To create a WebLogic server runtime, do the following:

  1. From the Window menu, select Preferences.
  2. In the Preferences dialog, expand Server and then select Installed Runtimes.
  3. Click the Add button to create a WebLogic runtime.
  4. Select the type of BEA WebLogic server runtime to create and click Next.
  5. Specify the correct paths for your installation of WebLogic.
  6. Click Finish to save your changes.

Tip: Set the highest J2EE version used for development to 1.3 since WebLogic Server only supports up to J2EE 1.3.

  1. From the menu, go to Window > Preferences.
  2. Select J2EE in the left pane. The J2EE page opens.
  3. Set Highest J2EE version used for development to 1.3 and click OK.

Loading the Web example

The YourCompanyExample project is a full featured, Web-based sample application that uses HTML pages, cascading style sheets (CSS) and Java Server Pages (JSP) to provide employees with common intranet services. The YourCo intranet site enables users to do these things:

In this part of the tutorial, you will build an entry page for a company intranet site similar to the entry page of the YourCo Web site. To get the correct look and feel, we will copy some files from the YourCompanyExample project into a separate, new project that you will create. As you work through the tutorial, you can refer back to the YourCompanyExample project to check your work.

When you start the workbench, one of several perspectives is displayed. Each perspective provides you with a specialized set of tools to support a different set of development tasks. When you create a new Web project or load a Web example project, the Web perspective opens and your focus is automatically switched. This perspective gives you easy access to the views and tools that you need to develop Web applications. Like many other menus, the File menu is context-sensitive so functions like creating new Web projects are easier to perform in the Web perspective.

To open the Web perspective:

  1. Click Window > Open Perspective > Other.
  2. In the Select Perspective dialog, click Web, then click OK.

    The Web perspective opens and the Web perspective icon is added to the Perspectives shortcut bar of the workbench.

Because you will reuse some files from the YourCompanyExample project, you need to load that example. To load the YourCompanyExample project:

  1. Click File > Import. The Import Wizard is displayed.
  2. Select WebLogic EAR file and click Next. The enterprise application import wizard is displayed.
  3. In the EAR file textbox, specify the following EAR file (where install_path is the directory where you have installed IBM Rational Developer):
    install_path\eclipse\plugins\com.ibm.etools.weblogic.scenario.yourco.doc\DefaultEAR.ear
  4. In the Target server field, select your WebLogic Server version.
  5. Click Finish to accept the default settings and load the example.

The YourCompanyExample project is now loaded and is seen in the Project Explorer view. The project may have JSP compilation errors but we can ignore these since JSPs are compiled and validated by WebLogic Server during server publishing, not when a project is built. To remove the errors from the Problems view:

  1. In the Project Explorer view, right-click YourCompanyExample and select Properties. The Properties dialog is displayed.
  2. Select Validation in the left pane of the Properties dialog.
  3. Check Override validation preferences.
  4. Uncheck JSP Compilation Validator.
  5. Click OK to save your changes.

A README.htm file can be found in the YourCompanyExample project folder. This file explains the features of the YourCo intranet site and gives instructions for setting up and running the application. You do not need to work through these now, but you may want to use them in the future.

A hierarchical view of the project is displayed in the Project Explorer view.

Under the folder Enterprise Applications is a project called DefaultEAR. Enterprise Application projects store meta information about the projects that are associated with them. This information is used when you publish a Web project. Expand DefaultEAR, then META-INF to see the files that the project contains.

You can associate more than one Web project (also referred to as a Web module) with each Enterprise Application project. Open application.xml to view a list of files associated with the DefaultEAR project; click the Source tab to view the XML code.

Exploring the YourCompanyExample project (optional)

Now that you have loaded the example, you can explore the application and view some of its files. To see an example of the kinds of pages you will be building:

  1. In the Project Explorer view, expand YourCompanyExample.

    Note: To quickly expand a project or folder, double click the project or folder name.

  2. Expand WebContent; double-click index.html. The file is opened in Page Designer. This editor has several pages:

    Design page: Enables you to edit files visually.
    Source page: Enables you to edit source code directly.
    For Windows Preview page: Shows you a close approximation of what the Web page will look like when it is viewed in a browser. You can also test links by clicking them in the Preview page.

    You can switch between pages at any time by clicking the tabs at the bottom of the editor area. When you have more than one file open, you can switch between them by clicking on the file name tabs at the top of the editor area.

    Note: The location and appearance of the file name tabs is configurable. Select Window > Preferences > Workbench > Appearance for options.

    Each file is displayed in the Page Designer page that you selected last. If it is not already selected, click the Design tab. Notice that the file contains a frameset. By default, the cursor is placed in the top left hand corner of the top frame.

    index.html displayed in Design page

  3. At the bottom of the Design page, click Source. The Source page opens, displaying the source HTML at the location of your cursor. Click the arrow in the top left corner of the editor to display the list of files included in the frameset. You can use this list to select a different file from the frameset.

    Title.html in the Source page

  4. For Windows At the bottom of the Design page, click Preview. Maximize the window by double-clicking the index.html tab to see more of the Preview page. Double-clicking the tab again will restore the window to its original size.

Now that you have explored the Web perspective and the different Page Designer pages, the next step is to start building your own Web application.

Terms of use | Feedback
(C) Copyright IBM Corporation 2002, 2004. All Rights Reserved.