Home
TOC Index |
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:http://java.sun.com/webservices/downloads/webservicestutorial.html
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 at
<JWSDP_HOME>
/docs/tutorial/examples/gs/,
which is the root directory for the source code for this application.The application consists of the following files that are either in the
/gs
directory or a subdirectory of/gs
.
/src/converterApp/ConverterBean.java
- The JavaBeans component that contains theget
andset
methods for theyenAmount
andeuroAmount
properties 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 theAnt
tool 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
Ant
development 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
bin
directories of the Java WSDP and J2SE SDK installations to the front of yourPATH
environment variable so that the Java WSDP startup scripts for Tomcat,Ant
, anddeploytool
override other installations.
Note: Most of the examples are distributed with a configuration file for version 1.4.1 ofAnt
, a portable build tool contained in the Java WSDP. If yourPATH
variable does not point to thebin
directory of the Java WSDP, many of theAnt
commands will not work because the version ofAnt
shipped with the Java WSDP sets thejwsdp.home
environment variable.
Creating the Build Properties File
In order to invoke many of the
Ant
tasks, you need to put a file namedbuild.properties
in 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.properties
file 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.properties
file) 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.properties
file in your home directory, do so now. The file will look like this:username=your_username
password=your_password
Note: For security purposes, make thebuild.properties
file unreadable to anyone but yourself.
The
tomcat-users.xml
file, which is created by the installer, looks like this:<?xml version='1.0'?> <tomcat-users> <role rolename="admin"/> <role rolename="manager"/> <role rolename="provider"/> <user username="your_username
" password="your_password
" roles="admin,manager,provider"/> </tomcat-users>
Home
TOC Index |
This tutorial contains information on the 1.0 version of the Java Web Services Developer Pack.
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.