|
<taglib:tutorial lesson="setup"/> This article explains how to set up the environment used thoughout this tutorial.
Setting up the development environment
Setting up the file structure for the Application Setting up the file structure for the Web-module Describing the Application Describing the Web-module Deploying the Application Binding the Web-module 1 Setting up the development environment Before we get started with the tutorial, we will need to set up our development environment. Our environment will consist of an unpacked Application holding a single module in the form of an unpacked Web-module. If you are not using the Orion Application Server, you might have to package the Application into an archive before deploying it on your Application Server. 2 Setting up the file structure for the Application First, we will create the file structure for the Application that will hold our Web-module. This can be done by following these steps 2.1 Step 1: Creating a directory In the '/orion/applications/' directory, create a new directory called 'taglib-tutorial'. 2.2 Step 2: Creating a META-INF directory In this directory ('/orion/applications/taglib-tutorial/') create a new subdirectory called 'META-INF'. The META-INF directory is where the Container will look for deployment information about our Application, as we will look at later. Your file structure should now look like in the following image:
3 Setting up the file structure for the Web-module With the file structure for our Application in place, its time to setup the file structure for our Web-module. An Application might hold a number of modules, such as Web-modules, Client-Application modules or EJB-modules. We will now set up the file structure for the Web-module that we will use throughout this tutorial in the following steps:
Step 1: Creating the directory that will hold the Web-module
Step 2: Creating the WEB-INF directory Step 3: Creating the classes directory Step 4: Creating the lib directory Step 5: Creating the package hierarchy Step 6: Creating the bean directory Step 7: Creating the validator directory Step 9: Creating the listener directory Step 9: Creating the function directory 3.1 Step 1: Creating the directory that will hold the Web-module In the '/orion/applications/taglib-tutorial/' directory create a new subdirectory called 'taglib-tutorial-web'. This is where you will put all your content, such as JSP or HTML pages, text files, images etc. 3.2 Step 2: Creating the WEB-INF directory In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/' directory, create a new subdirectory called 'WEB-INF'. The WEB-INF directory is where the Container will look for deployment information about our Web-module. 3.3 Step 3: Creating the classes directory In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/WEB-INF/' directory, create a new subdirectory called 'classes'. The classes directory is where the Container will look for classes used in our Web-module. 3.4 Step 4: Creating the lib directory In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/WEB-INF/' directory, create a new subdirectory called 'lib'. The lib directory is where the Container will look for class-libraries used in our Web-module. 3.5 Step 5: Creating the package hierarchy In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/WEB-INF/classes/' directory, create a new subdirectory called 'com'. In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/WEB-INF/classes/com/' directory, create a new subdirectory called 'acme'. In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/WEB-INF/classes/com/acme/' directory, create a new subdirectory called 'tag'. The '/com/acme/tag/' file structure is the package space for the Tags that we are going to develop throughout this tutorial. 3.6 Step 6: Creating the bean directory In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/WEB-INF/classes/com/acme/' directory, create a new subdirectory called 'bean'. The '/com/acme/bean/' file structure is the package space for the beans that we are going to develop throughout this tutorial. 3.7 Step 7: Creating the validator directory In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/WEB-INF/classes/com/acme/tag' directory, create a new subdirectory called 'validator'. The '/com/acme/tag/validator/' file structure is the package space for the validators that we are going to develop throughout this tutorial. 3.8 Step 9: Creating the listener directory In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/WEB-INF/classes/com/acme' directory, create a new subdirectory called 'listener'. The '/com/acme/function/' file structure is the package space for the Listeners that we are going to develop throughout this tutorial. 3.9 Step 9: Creating the function directory In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/WEB-INF/classes/com/acme' directory, create a new subdirectory called 'function'. The '/com/acme/function/' file structure is the package space for the Expression Language functions that we are going to develop throughout this tutorial. Your file structure should now look like in the following image:
4 Describing the Application In order for our Container to make sense of our Application, we will need to describe it. This is done in a Application descriptor. The Application descriptor is a file named 'application.xml' that resides in the '/META-INF/' directory of the Application in question. We will add the descriptor in the following steps: 4.1 Create the application-xml file In the '/orion/applications/taglib-tutorial/META-INF/' directory create a new file called 'application.xml' with the following content:
The first line above defines this file as a version 1.0 XML file. The second line defines the format of the XML to conform to the Application 1.2 definitions, and where this definition can be found. 4.2 Adding a display name Continue with the following:
The line above defines the display name of our Application. Most deployment-tools will display this during deployment. 4.3 Adding a Web-module Continue with the following:
Above, we define that our Application will contain a Web-module that can be found in the 'taglib-tutorial-web' directory, and that the default Context root for this Web-module will be '/taglib'. If the Web-module is deployed, the Container will look for a Web-module descriptor in a subdirectory called 'WEB-INF' under the specified directory. 4.4 Ending the descriptor Finish off the descriptor with the following:
Make sure that you store the file in the '/orion/applications/taglib-tutorial/META-INF' directory as 'application.xml'. By now, your application.xml should look like this. 5 Describing the Web-module Just as with the Application, we need to describe our Web-module so that the Container can use it. This is done in a Web-module descriptor. The descriptor is a file called 'web.xml' that resides in the '/WEB-INF/' directory of the Web-module. We will now create a file called web.xml that we will put in the "WEB-INF"-directory, where it is supposed to be. This file holds the configuration settings for our Web-module. Please notice that there is a lot of things you can configure in this file, and that we will only set up a minimum subset at this time. This will be done in the following steps:
Creating the web.xml file
Adding a display name and a description Defining the welcome-page Ending the descriptor 5.1 Creating the web.xml file In the '/orion/applications/taglib-tutorial/taglib-tutorial-web/WEB-INF/' directory create a new file called 'web.xml' with the following content:
The first line above defines this file as a version 1.0 XML file. The second line defines the format of the XML to conform to the web-app 2.2 definitions, and where this definition can be found. 5.2 Adding a display name and a description Continue with the following:
The lines above define the display-name and the description of our Web-module. Most deployment tools will display this upon deployment. 5.3 Defining the welcome-page Continue with the following:
The lines above will tell the server what default page to display if a request is made without any specified filename. 5.4 Ending the descriptor End the file with the following line:
Your web.xml should now look like this. 6 Deploying the Application In order to deploy your unpacked Application on the Orion Application Server, follow the instructions below. Edit the file '/orion/config/server.xml' and add the following entry:
This will tell our server that we want the "taglib-tutorial" Application bound to this server. The Container will look into the subdirectory named 'META-INF' of the specified directory for deployment information. Make sure you save the file. 7 Binding the Web-module We will now bind the Web-module to the default web-site that comes with a default installation of Orion. Edit the file '/orion/config/default-web-site.xml' and add the following entry:
This will tell the server that we want the "taglib-tutorial-web" Web-module that is bound to the "taglib-tutorial" Application to be available on this site under the URL "http://localhost/taglib". The Container will look into the subdirectory named 'WEB-INF' of the directory specified in the Application descriptor for deployment information. Please substitute 'localhost' with your server name/ip if needed. make sure that you save the file. We are now ready to start developing! Continue with lesson 1. Copyright © 2005 IronFlare AB |