C H A P T E R  4

Tutorial--Section 1.1
Application Infrastructure

This chapter describes how to create the Suntrademark ONE Application Framework (also known as Application Framework, App Framework, S1AF, and JATO) application infrastructure needed for all subsequent tasks.


Task 1: New Sun ONE Web Application

Before developing any pages, you need to create the Sun ONE Application Framework application infrastructure (the WAR directory structure and supporting files). This is a onetime requirement for each Sun ONE Application Framework application.

Create an Application Wizard

Before you create the application, you need to decide where the application should be located. Typically, developers develop the application directly in the webapps directory of a servlet container so the application can be tested without deploying it to the target runtime environment. Since you are already using the Suntrademark ONE Studio (Studio), you can locate the application anywhere and use the built-in Suntrademark ONE Application Server 7 module to test it in place.

1. Select the Sun ONE Studio menu option File -> New.

The Choose Template panel displays.

This figure shows the Choose Template panel. 

2. Expand the Sun ONE Application Framework folder.

3. Select Application.

4. Click Next.

The Application Location panel displays.

This figure shows the Application Location panel. 

The default base directory is your Sun ONE Studio user-dir, which might be different than the one shown in this example. You can choose any existing directory to be your base directory for your Sun ONE Application Framework applications.



Note - Many developers use the webapps directory of the servlet container in which the application is deployed.

Later in this tutorial, you will see how to run your Sun ONE Application Framework Web application using the Sun ONE Studio, so you can put your Web application anywhere you want.



5. Enter JatoTutorial in the Web Context Name field.

The New App Directory field is populated after you make entries in the Base Directory and Context Name fields.

6. Click Next.

The Application Properties panel displays.

This figure shows the Application Properties panel. 

The fields on this panel are populated using the value of the Web Context Name field from the previous panel.

For this tutorial, accept the default values.

7. Click Next.

The Module Properties panel displays.

This figure shows the Module Properties panel. 

For this tutorial, accept the default values.

8. Click Finish.

9. Click OK.

The application is created.



Note - The processing time depends upon your machine.



The new application displays in the Sun ONE Application tree in the Sun ONE Studio Explorer which is labeled Sun ONE Web Apps.

10. Expand the modules node in the Sun ONE Web Apps Explorer to see the application layout and observe the code in the two servlet classes that were created.

 The left figure shows the application layout. The right figure shows the code in the two servlet classes that were created.

Application Servlet

The application servlet, JatoTutorialAppServletBase, has no special meaning to the application except that it is meant to be a super class for all module servlets in the application.

The Sun ONE Application Framework module servlets have events that can be implemented to customize and control the session and request life cycle.

For example:

It is common that all module servlets within the same application require the same behavior for all of these events. Therefore, it is a good idea to implement such behavior for these events in a class that all module servlets can extend.

However, technically speaking, the application servlet is not required. You can customize the hierarchy of the module servlet as long as that hierarchy derives from the Sun ONE Application Framework's com.iplanet.jato.ApplicationServletBase file.

This application has only one module, and by definition, one module servlet. So the role of the application servlet is not as beneficial as it would be in multi-module applications.

Module Servlet

The module servlet, MainModuleServlet, is the actual servlet that is invoked for every request. All access to the application goes through this front controller servlet before control is handed to the appropriate request handler class (implemented later in this tutorial).

Not much code is required in this class. All of the necessary request handling code is located in the Sun ONE Application Framework's com.iplanet.jato.ApplicationServletBase file. Advanced developers can gain some insight on how requests are handled by reviewing the source code in the com.iplanet.jato.ApplicationServletBase class.

Advanced Tip - Modules

Notice that if the main module folder is selected, its properties are reflected in the property sheet at the bottom of the Studio Explorer window. Notice that its Module property is True. By changing it to False, this module becomes an ordinary folder/package, and the entries in the web.xml file (a standard Web application configuration file) for the MainModuleServlet are removed.

You can make any ordinary folder a Sun ONE Application Framework module by right-clicking the folder and selecting the Convert to Module action. You are then prompted to select a Java servlet class from that folder to be the module servlet, or you can provide a name to create a new one.