C H A P T E R  1

Getting Started

This chapter explains what you must do before starting the Sun ONE Studio 5 Web Application tutorial. The topics covered in this chapter are:



Note - There are several references in this book to the CDShopCart application files. These files include a completed version of the tutorial application, a readme file describing how to run the completed application, and SQL scripts for creating the required database table. These files are compressed into a zip file you can download from the Sun ONE Studio 5 Developer Resources portal at http://forte.sun.com/ffj/documentation/tutorialsandexamples.html




Obtaining and Installing the Required Software

The following items are required to create and run the tutorial.

The Sun ONE Studio 5, Standard Edition installer installs both products unless it detects a supported version of the Sun ONE Application Server 7 already installed. The Solaristrademark 9 Update 2 Operating Environment, for example, includes an installation of Sun ONE Application Server 7.
You can obtain the Sun ONE Studio 5, Standard Edition software from:
The Sun ONE Studio 5, Standard Edition installer will not run if you do not have the J2SE SDK on your system. If you do have a J2SE SDK on your system, the installer will start and then verify whether the J2SE SDK you are using is a version required by the IDE and the Sun ONE Application Server 7 for your platform. If you do not have the required version, the installer will quit, displaying a message that you must install the correct version before proceeding. You can obtain the J2SE SDK from the same locations as the IDE.
This tutorial uses the PointBase database. PointBase is installed with the Sun ONE Studio 5, Standard Edition software, in the subdirectory that contains the Sun ONE Application Server 7 software. If your IDE and application server were installed separately, your application server may or may not include PointBase software. If it does not, you must download and install PointBase software manually. Instructions are provided in the Sun ONE Application Server 7 Getting Started Guide. Alternatively, Appendix C describes how to create the tutorial application with an Oracle database.
The tutorial SQL scripts are described in Appendix B. Files of these SQL scripts are included in the application files of the CDShopCart tutorial, available from the Sun ONE Studio 5 Developer Resources portal. Creating the Tutorial Database Table describes how to install the tutorial database table in a PointBase database. Appendix C describes how to install the tutorial tables in an Oracle database.
The tutorial is a web application, which requires a web server. This tutorial uses the web server component of Sun ONE Application Server 7.
You need a web browser to view the tutorial application pages. This can be either Netscape Communicatortrademark or Microsoft's Internet Explorer.

You can access general system requirements from the release notes or from the Sun ONE Studio 5 Developer Resources portal's Documentation page at http://forte.sun.com/ffj/documentation/.


Starting the Software

This section describes how to start the Sun ONE Studio 5 IDE and Sun ONE Application Server 7 after the software has been installed.

Starting the IDE

There are several ways to start the Sun ONE Studio 5 IDE. Only one is described here. For more options, see the Sun ONE Studio 5, Standard Edition Getting Started Guide.

To start the IDE:

single-step bulletStart the Sun ONE Studio 5 IDE by running the program executable.

The s1studio-install-directory variable stands for the IDE's home directory, which is by default $HOME/studio5_se (UNIX standard user) or /opt/studio5_se (UNIX superuser).

Starting the Application Server

Before starting this section, you must have write access to an application server domain. The default domain is created during installation and requires superuser privileges (administrator privileges on Microsoft Windows systems or root privileges in Solaris or Linux environments) to access. If your userid has superuser privileges, you can start the application server using all default settings, as described in the next section. Standard users (without superuser privileges) must use the procedures described in Starting the Admin Server (Standard User).

Starting the Admin Server (Superuser)

If you have started the admin server previously, confirm whether it is running. See Confirming Sun ONE Application Server 7 as the Default Server for information. If this is the first time you have started the admin server, start with this section.

To start the admin server:

1. In the IDE, select the Runtime tab of the Explorer.

The Runtime pane of the Explorer displays the Server Registry node, among other nodes. This node contains subnodes for all the installed web and application servers, and a node showing which servers are the default servers.

2. Select the Server Registry node.

A query window pops up, asking whether you want to start the admin server. This refers to the default domain's admin server, which can only be run by a privileged user.

3. Click OK to start the default admin server.

The IDE starts the default admin server and configures Sun ONE Application Server 7 as the IDE's default application server.

4. Expand the Server Registry node, the Installed Servers node, and the Sun ONE Application Server 7 node.

The Server Registry in the Explorer looks like this:

The Default Servers node in the Runtime page of the Explorer shows the application server node is localhost:4848.[ D ] 

Now, start the server instance, as described in Starting the Application Server Instance.

Starting the Admin Server (Standard User)

If your userid does not have superuser privileges, a superuser must create a domain for you before you start this section. The procedures are described in the Sun ONE Studio 5, Standard Edition Getting Started Guide.

If you have started the IDE previously, created an admin server, and started it, confirm now whether it is running by using the procedures described in Confirming Sun ONE Application Server 7 as the Default Server. If this is the first time you have started the admin server, start with this section.

Before starting the procedures described in this section, you will need values of several properties of your domain. Your administrator can provide these for you. Use the following table to record your values to these properties.:

TABLE 1-1 Admin Server Property Values

Admin Server Properties

Your Value

Admin Server Host

 

Admin Server Port

 

User Name

 

User Password

 

Domain

 


To start the admin server:

1. In the IDE, select the Runtime tab of the Explorer.

The Runtime pane of the Explorer displays the Server Registry node, among other nodes. This node contains subnodes for all the installed web and application servers, and a node showing which servers are the default servers.

2. Select the Server Registry node.

A query window pops up, asking whether you want to start the admin server. This refers to the admin server of the default domain, which can only be run by a privileged user.

If you click OK, this action creates and starts an admin server that you cannot use. Click Cancel.

3. Add your admin server to the IDE.

a. Expand the Server Registry node and the Installed Servers node.

b. Right-click the Sun ONE Application Server 7 node and choose Add Admin Server.

The Add Admin Server dialog box is displayed.

Add Admin Server dialog box with no values for Admin Server Host, Port, User Name,Password, and domain1 for Domain. Buttons are OK, Cancel, and Help. 

c. Type in your values from TABLE 1-1 and click OK.

If an error message appears, stating that the IDE could not locate the admin server, but will start it if it is local, click OK to close the error window. A progress window appears, showing the admin server process starting up.

A new admin server node is generated in the Explorer. In the following screen shot, the new admin server's host is localhost and port number is 4850.

Runtime tab of Explorer showing localhost:4850 (new admin server instance) under Sun ONE Application Server 7 node. 

4. Create an application server instance.

a. Right-click the new admin server node and choose Create a Server Instance.

The Enter Server Instance Values dialog box is displayed.

b. Type in a name and port number.

For example, you could type MyServer and 4855.



Note - On Solaris and Linux systems, port numbers below 1024 are reserved. Use a port number above 1023. On all systems, do not use the port number used by the default application server, which is 80.



c. Click OK.

This action starts the admin server, which you can verify by messages in the output window and status bar. The new server instance is created in the IDE.

Segment of Runtime tab of the Explorer window showing new application server node is MyServer(localhost:82). 

5. Set the default application and web server by right-clicking the new server instance and choosing Set As Default.

6. Expand the Default Servers node to verify this action.

The default servers for J2EE applications and web tier applications show the new server as the default.

 [ D ] 

Now start the server instance, as described in the next section.

Starting the Application Server Instance

When you are test deploying and deploying applications during development, the IDE starts the application server instance automatically as long as the admin server is running. In this section, you start the application server instance manually in order to perform some operations described later in this chapter.

All users start the server instance as follows:

1. Right-click the application server node and choose Status.



Note - If this node is not displayed, select the admin server instance node and choose Refresh.



The Sun ONE Application Server Instance Status dialog box is displayed, as shown (your instance label may be different).

Sun ONE Application Server Instance Status window. Buttons are Start Server, Close, and Help. 

2. Click the Start Server button.

(If the dialog box has a Stop Server button, the server is already running.)

On Microsoft Windows systems, a command window appears, displaying progress messages.

The server is started when the Server Instance Status window displays Status: Running.

3. Click Close on the instance status dialog box.

Now, proceed to Creating the Tutorial Database Table.

Confirming Sun ONE Application Server 7 as the Default Server

If you have started Sun ONE Application Server 7 before, this is how you confirm that it is still the default server:

1. In the IDE, select the Runtime tab of the Explorer.

2. Expand the Server Registry node and its Default Servers subnode.

If the Web Tier Applications node's label is server-instance(server-hostname:server-port-number), as shown, then Sun ONE Application Server 7 is the default web server. Go to the next section. Otherwise, continue with the next step.

The Default Servers node in the Runtime pane of the Explorer shows the web server is MyServer(localhost:82). 

3. Find your web server instance under the Installed Servers node, right-click it, and choose Set As Default.

Your server is set as the default server for J2EE and Web Tier applications.


Creating the Tutorial Database Table

Before you can start the CDShopCart tutorial, you must create and install a database table in the PointBase Network Server database. Use the SQL script in Appendix B to create these tables. A script file, CDCatalog_pb.sql, is also available within the cdshop.zip file for the CDShopCart tutorial, available from:

http://forte.sun.com/ffj/documentation/tutorialsandexamples.html



Note - If your Sun ONE Studio 5 IDE and Sun ONE Application Server 7 were not installed together, actions you must take to connect the IDE and the application server to the PointBase database software are described in the Sun ONE Studio 5, Standard Edition Getting Started Guide. You must perform these before beginning the following procedure.



To install the tutorial table in a PointBase database:

1. Start the PointBase Server from the IDE by choosing Tools right arrow PointBase Network Server right arrow Start Server.

The PointBase Network Server window is displayed. Minimize the window.

2. Start the PointBase Console from the IDE by choosing Tools right arrow PointBase Network Server right arrow Start Console.

The Connect To Database dialog box appears, showing values for the PointBase driver to the default sample database.

3. Change the word sample at the end of the URL field to cdshopcart, as shown.

PointBase's Connect To Database dialog box showing the example values entered.[ D ] 

4. Set the Create New Database option and click OK.

The PointBase Console is displayed. Wait until the status message ending in "Ready" is displayed before proceeding.

5. Copy the PointBase script from Script for a PointBase Database and paste it into the SQL entry window of the Console.

Alternatively, if you have the CDCatalog_pb.sql file from the tutorial source zip file, do this:

a. Choose File right arrow Open to display the file browser dialog box.

b. Use the file browser to locate the CDCatalog_pb.sql file and click Open.

6. Choose SQL right arrow Execute All.

The message window confirms that the script was executed. (Ignore the initial message beginning "Cannot find the table..." This is a harmless error and appears because there is a DROP statement for a table that has not yet been created yet. This DROP statement will be useful in the future if you want to rerun the script to initialize the table.)

7. Test that you have created the table by clearing the SQL entry window (Window right arrow Clear Input) and typing:

select * from CD;

8. Choose SQL right arrow Execute.

Your console should display the CD table.

PointBase console showing the example select statement as input and the CD table and its data as output. 


Note - If your display does not look like this table, choose Window right arrow Windows to change the display type.



9. Close the PointBase Console window.

The CDCatalog script creates the database schema shown in TABLE 1-2.

TABLE 1-2 CDCatalog Database Table

Table Name

Columns

Primary Key

Other

CD

id

yes

 

cdtitle

 

 

artist

 

 

country

 

 

price

 

 


The CD table is populated with the records shown in TABLE 1-3.

TABLE 1-3 CD Table Records

ID

CDtitle

Artist

Country

Price

1

Yuan

The Guo Brothers

China

14.95

2

Drums of Passion

Babatunde Olatunji

Nigeria

16.95

3

Kaira

Tounami Diabate

Mali

13.95

4

The Lion is Loose

Eliades Ochoa

Cuba

12.95

5

Dance the Devil Away

Outback

Australia

14.95


Now you are ready to start the tutorial application. Either continue to Chapter 2 to get an overview of the application you will build, or go directly to Chapter 3 and start building it.