|
FAQ
History |
|
Search
Feedback |
Setting Up
Note: Before you start developing the example applications, follow the instructions in About This Tutorial, then continue with this section.
Getting the Example Code
The source code for the example is in <
JWSDP_HOME>/docs/tutorial/examples/gs/, a directory that is created when you unzip the tutorial bundle. If you are viewing this tutorial online, you can download the tutorial bundle from:Layout of the Example Code
In this example application, the source code directories are organized according to the "best practices approach to Web services programming", which is described in more detail in the file
<JWSDP_HOME>/docs/tomcat/appdev/deployment.html. Basically, the document explains that it is useful to examine the runtime organization of a Web application when creating the application. A Web application is defined as a hierarchy of directories and files in a standard layout. Such a hierarchy can be accessed in its unpacked form, where each directory and file exists in the file system separately, or in a packed form known as a Web Application Archive, or WAR file. The former format is more useful during development, while the latter is used when you distribute your application to be installed.To facilitate creation of a WAR file in the required format, it is convenient to arrange the files that Tomcat uses when executing your application in the same organization as required by the WAR format itself. In the example application,
<JWSDP_HOME>/docs/tutorial/examples/gs/is the root directory for the source code for this application.The application consists of the following files that are either in the/gsdirectory or a subdirectory of/gs.
/src/converterApp/ConverterBean.java- The JavaBeans component that contains thegetandsetmethods for theyenAmountandeuroAmountproperties used to convert U.S. dollars to Yen and convert Yen to Euros./web/index.jsp- The Web client, which is a JavaServer Pages page that accepts the value to be converted, the buttons to submit the value, and the result of the conversion./web/WEB-INF/web.xml- the deployment descriptor for this application. In this simple example, it contains a description of the example application.build.xml- The build file that uses theAnttool to build and deploy the Web application.More information about WAR files can be found in Web Application Archives.
A key recommendation of the Tomcat Application Developer's Manual is to separate the directory hierarchy containing the source code from the directory hierarchy containing the deployable application. Maintaining this separation has the following advantages:
- The contents of the source directories can be more easily administered, moved, and backed up if the executable version of the application is not intermixed.
- Source code control is easier to manage on directories that contain only source files.
- The files that make up an installable distribution of your application are much easier to select when the deployment hierarchy is separate.
As discussed in Creating the Build and Deploy File for Ant, the
Antdevelopment tool makes the creation and processing of this type of directory hierarchies relatively simple.The rest of this document shows how this example application is created, built, deployed, and run. If you would like to skip the information on creating the example application, you can go directly to Quick Overview.
Setting the PATH Variable
It is very important that you add the
bindirectories of the Java WSDP, Java 2 Software Development Kit, Standard Edition (J2SESDK), and Ant installations to the front of your
PATHenvironment variable so that the Java WSDP startup scripts for Tomcat override other installations.In addition, most of the examples are distributed with a configuration file for version 1.5.1 of
Ant, a portable build tool contained in the Java WSDP. The version ofAntshipped with the Java WSDP sets thejwsdp.homeenvironment variable, which is required by the example build files. To ensure that you use this version ofAnt, you must add<JWSDP_HOME>/jakarta-ant-1.5.1/binto the front of yourPATH.Creating the Build Properties File
In order to invoke many of the
Anttasks, you need to put a file namedbuild.propertiesin your home directory. On the Solaris operating system, your home directory is generally of the format/home/your_login_name. In the Windows operating environment (for example on Windows 2000), your home directory is generallyC:\Documents and Settings\yourProfile.The
build.propertiesfile contains a user name and password in plain text format that match the user name and password set up during installation. The user name and password that you entered during installation of the Java WSDP are stored in <JWSDP_HOME>/conf/tomcat-users.xml.For security purposes, the Tomcat Manager application verifies that you (as defined in the
build.propertiesfile) are a user who is authorized to install and reload applications (as defined intomcat-users.xml) before granting you access to the server.If you have not already created a
build.propertiesfile in your home directory, do so now. The file will look like this:
Note: For security purposes, make the
build.propertiesfile unreadable to anyone but yourself.
The
tomcat-users.xmlfile, which is created by the installer, looks like this:
|
FAQ
History |
|
Search
Feedback |
All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.