Web Application Developers Guide
Web Application Developers Guide
Developers Guide
Borland
VERSION 8
JBuilder
Refer to the file deploy.html located in the redist directory of your JBuilder product for a complete list of files that
you can distribute in accordance with the JBuilder License Statement and Limited Warranty.
Borland Software Corporation may have patents and/or pending patent applications covering subject matter in this
document. Please refer to the product CD or the About dialog box for the list of applicable patents. The furnishing of
this document does not give you any license to these patents.
COPYRIGHT 19972002 Borland Software Corporation. All rights reserved. All Borland brand and product names
are trademarks or registered trademarks of Borland Software Corporation in the United States and other countries.
All other marks are the property of their respective owners.
For third-party conditions and disclaimers, see the Release Notes on your JBuilder product CD.
Printed in the U.S.A.
JBE0080WW21002webapps 3E3R1002
0203040506-9 8 7 6 5 4 3 2 1
PDF
Contents
Chapter 1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 3-7
. 3-7
. 3-8
3-10
3-12
3-13
3-13
3-15
. . . . 2-7
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 4-2
. 4-3
. 4-3
. 4-4
. 4-5
. 4-6
. 4-6
. 4-6
. 4-6
. 4-7
. 4-7
. 4-8
. 4-8
. . . . 2-8
Chapter 5
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 5-1
. 5-1
. 5-3
. 5-4
. 5-5
. 5-6
. 5-6
. 5-8
. 5-9
5-10
5-11
.
.
.
.
.
.
.
.
5-11
5-12
5-12
5-13
Introduction
WebApp properties . . . . .
The WebApp page . . . .
The Directories page. . .
The Classes page . . . . .
The Dependencies page .
The Manifest page . . . .
The WAR file . . . . . . . . . .
Applets in a WAR file . . . .
1-1
Documentation conventions . . . . . . . .
Developer support and resources . . . . .
Contacting Borland Technical Support.
Online resources . . . . . . . . . . . . .
World Wide Web . . . . . . . . . . . . .
Borland newsgroups . . . . . . . . . . .
Usenet newsgroups . . . . . . . . . . .
Reporting bugs . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1-4
1-5
1-5
1-6
1-6
1-7
1-7
1-7
Servlets . . . . . . . . . . . . . . . . . . .
JavaServer Pages (JSP). . . . . . . . . . .
InternetBeans Express . . . . . . . . . . .
Struts . . . . . . . . . . . . . . . . . . . .
JavaServer Pages Standard Tag
Library (JSTL). . . . . . . . . . . . . . .
Applets . . . . . . . . . . . . . . . . . . .
Deciding which technologies to use in
your web application . . . . . . . . . .
The basic web application development
process. . . . . . . . . . . . . . . . . . .
Web applications vs. distributed
applications . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
2-2
2-3
2-5
2-5
. . . . 2-6
. . . . 2-6
3-1
. . . . . 3-1
. . . . . 3-2
. . . . . 3-2
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Chapter 3
The WebApp . . . . . . . . . . . . . . .
Web archive (WAR) files . . . . . . . .
Tools for working with WebApps and
WAR files . . . . . . . . . . . . . . . .
Creating a WebApp with the Web
Application wizard . . . . . . . . . .
The WebApp and its properties . . . .
Root directory. . . . . . . . . . . . .
Deployment descriptors . . . . . . .
.
.
.
.
.
.
.
.
4-1
. . . . 2-9
.
.
.
.
.
.
.
.
2-1
.
.
.
.
.
.
.
.
.
.
.
.
Chapter 4
Chapter 2
.
.
.
.
.
.
.
.
3-3
3-5
3-5
3-6
5-1
Chapter 6
Action wizard . . . . . . . . . . . . . . . .
WebApp And Name For Action page .
Configuration Information page . . . .
JSP From ActionForm wizard . . . . . . .
WebApp, JSP And ActionForm page .
Tag Types For ActionForm Fields In
JSP page . . . . . . . . . . . . . . . . .
Specify The Options For Creating
This Struts JSP page . . . . . . . . . .
Struts Conversion wizard . . . . . . . . .
Specify The Pages To Convert To
Struts page . . . . . . . . . . . . . . .
Tags To Convert page . . . . . . . . . .
Specify The Options For Converting
Tags To Struts page . . . . . . . . . .
Struts Config Editor . . . . . . . . . . . . .
Struts framework implementations
in JBuilder . . . . . . . . . . . . . . . . .
Creating a Struts-enabled web application
in JBuilder . . . . . . . . . . . . . . . . . . .
6-1
. . 6-3
. . 6-4
. . 6-5
. . 6-5
.
.
.
.
.
.
.
.
. 6-6
. 6-9
. 6-9
. 6-11
. 6-12
. 6-12
. 6-12
. 6-13
Chapter 7
7-1
. . 7-2
. . 7-3
.
.
.
.
.
.
7-5
7-5
7-6
7-6
7-8
7-9
.
.
.
.
.
.
. 8-11
. 8-12
. 8-12
. 8-13
. 8-13
. 8-14
. 8-14
. 8-16
9-1
.
.
.
.
.
.
.
.
.
.
.
.
. 9-1
. 9-3
. 9-4
. 9-7
Chapter 10
8-1
.
.
.
.
.
.
. 8-11
Chapter 8
. 8-8
. 8-9
. 8-9
8-10
8-10
Chapter 9
. . 7-3
.
.
.
.
.
.
.
.
.
.
.
8-3
8-3
8-3
8-5
8-6
8-6
. . 8-7
. . 8-7
. . 8-8
ii
10-1
. . . 10-2
. . . 10-2
. . . 10-3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 10-5
. 10-9
10-12
10-13
10-14
10-14
10-15
10-16
10-17
10-17
Chapter 11
11-1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 11-1
. 11-1
. 11-2
. 11-2
. 11-2
. 11-3
. 11-3
. 11-4
. . . . 11-5
12-1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 12-2
. 12-2
. 12-3
. 12-4
. 12-6
. 12-7
12-10
12-11
12-12
12-12
12-13
12-14
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
12-14
12-14
12-15
12-16
12-16
12-17
Chapter 13
13-1
.
.
.
.
.
.
.
.
. 13-8
.13-11
.13-11
.13-11
13-15
13-15
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 14-5
. 14-6
. 14-6
. 14-7
. 14-8
14-10
14-10
14-10
.14-11
14-12
14-12
14-13
14-14
14-15
14-15
Chapter 12
WebApp DD Editor context menu . . .
WebApp Deployment Descriptor page
Context Parameters page . . . . . . . .
Filters page . . . . . . . . . . . . . . . .
Listeners page . . . . . . . . . . . . . .
Servlets page . . . . . . . . . . . . . . .
Tag Libraries page . . . . . . . . . . . .
MIME Types page . . . . . . . . . . . .
Error Pages page . . . . . . . . . . . . .
Environment Entries page . . . . . . .
EJB References page . . . . . . . . . . .
Local EJB References page . . . . . . .
Resource Manager Connection Factory
References page . . . . . . . . . . . .
Resource Environment References . . .
Login page . . . . . . . . . . . . . . . .
Security page . . . . . . . . . . . . . . .
Security constraints . . . . . . . . .
Web resource collections. . . . . . .
.
.
.
.
.
.
Chapter 14
. . . . 11-4
.
.
.
.
.
.
. 13-2
. 13-2
. 13-3
. 13-5
. 13-5
. 13-5
. 13-8
. 13-8
iii
14-1
14-2
14-2
14-2
14-3
14-4
14-5
14-5
. . 14-16
. . 14-19
. . 14-20
. . 14-20
. . 14-21
. . 14-21
. . 14-22
. . 14-23
Chapter 15
Chapter 18
15-1
. . . 15-2
. . . 15-3
.
.
.
.
.
.
.
.
. 15-4
. 15-4
. 15-4
. 15-6
. . . 15-6
Chapter 16
16-1
. . . 16-2
. . . 16-2
. . . 16-2
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
18-2
18-2
18-2
18-3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
18-5
18-5
18-6
18-8
18-8
18-8
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
17-1
.
.
.
.
.
.
.
.
.
Chapter 17
Step 1: Creating the project . . . . . . . . .
Step 2: Selecting a server . . . . . . . . . .
Step 3: Creating the WebApp . . . . . . . .
Step 4: Creating the servlets . . . . . . . .
Step 5: Creating the data module. . . . . .
Step 6: Adding database components to
the data module . . . . . . . . . . . . . .
Step 7: Creating the data connection to the
DBServlet . . . . . . . . . . . . . . . . . .
Step 8: Adding an input form to
FormServlet . . . . . . . . . . . . . . . . .
Step 9: Adding code to the DBServlet
doPost() method . . . . . . . . . . . . . .
Step 10: Adding code to render the
Guestbook SIGNATURES table. . . . . .
What the doGet() method does . . . . .
Step 11: Adding business logic to the
data module . . . . . . . . . . . . . . . .
Step 12: Compiling and running your
project . . . . . . . . . . . . . . . . . . . .
.
.
.
.
Chapter 19
. . . 16-3
. . . 16-7
. . . 16-7
18-1
.
.
.
.
. 17-2
. 17-2
. 17-3
. 17-4
. 17-9
. . 17-10
.
.
.
.
.
19-1
19-2
19-2
19-2
19-3
19-5
. . . . . 19-6
. . . . . 19-8
. . . . . 19-9
. . . . .19-11
. . . . 19-12
. . . . 19-12
. . . . 19-13
Chapter 20
. . 17-13
. . 17-14
. . 17-15
. . 17-16
. . 17-17
. . 17-18
. . 17-19
iv
20-1
.
.
.
.
20-2
20-2
20-2
20-3
. 20-5
. 20-6
. 20-7
Chapter 21
. . . . 20-7
. . . . 20-8
. . . . 20-9
. . . . 20-9
. . . 20-10
. . . 20-10
. . . 20-11
. . . 20-12
Index
21-1
. . 21-2
. . 21-3
. . 21-4
. . 21-5
. . 21-8
. . 21-9
I-1
Tables
1.1
1.2
2.1
3.1
4.1
4.2
5.1
6.1
7.1
7.2
9.1
10.1
10.2
12.1
12.2
12.3
.
.
.
.
.
.
.
.
.
.
1-4
1-5
2-1
3-2
4-4
.
.
.
.
.
.
.
.
.
.
4-5
5-2
6-3
7-2
7-8
. . 9-3
. . 10-8
. 10-10
. . 12-2
. . 12-4
. . 12-5
vi
. . 12-8
.
.
.
.
.
.
.
.
.
.
.
.
.
.
12-18
. 13-4
. 13-5
. 13-7
. 13-8
13-10
.13-11
13-13
13-15
. 14-3
. 15-2
. 15-5
. 15-5
. 16-6
Figures
3.1
3.2
3.3
3.4
3.5
3.6
3.7
3.8
3.9
5.1
5.2
5.3
5.4
5.5
5.6
5.7
8.1
8.2
8.3
8.4
8.5
8.6
8.7
8.8
8.9
. 3-4
. 3-5
. 3-8
. 3-9
. 3-11
. 3-12
. 3-13
. 3-14
. 3-14
. 5-3
. 5-3
. 5-7
. 5-8
. 5-9
. 5-9
. 5-10
. 8-2
. 8-4
. 8-5
. 8-6
. 8-7
. 8-7
. 8-8
. 8-9
. 8-10
vii
. 8-10
. 8-11
. 8-11
. 8-12
. 8-13
. 8-13
. 8-14
10-15
10-16
10-16
. 12-3
. 12-4
. 12-5
. 12-6
. 12-7
. 12-8
. 12-9
12-10
.12-11
12-12
12-13
12-13
12-14
12-15
. 12-15
. 12-16
13.7
13.8
15.1
15.2
16.1
16.2
18.1
18.2
19.1
20.1
20.2
. 12-17
.
.
.
.
.
.
.
12-18
. 13-3
. 13-4
. 13-6
. 13-6
. 13-9
. 13-9
viii
13-12
13-12
. 15-7
. 15-7
. 16-8
. 16-8
. 18-3
. 18-7
. 19-3
. 20-3
20-12
Tutorials
Creating a simple servlet . . . . . . . . . . .
Creating a servlet that updates a guestbook
Creating a JSP using the JSP wizard . . . . .
Creating a servlet with InternetBeans
Express . . . . . . . . . . . . . . . . . . . .
. . 16-1
. . 17-1
. . 18-1
. . 19-1
ix
Chapter
Introduction
Chapter1
Web Development is a
feature of JBuilder
Enterprise. Applet
development is a feature
of all editions of JBuilder
Introduction
1-1
Introduction
1-2
Introduction
Introduction
1-3
Documentation conventions
Documentation conventions
The Borland documentation for JBuilder uses the typefaces and symbols
described in the following table to indicate special text.
Table 1.1
1-4
Typeface
Meaning
Monospaced type
Bold
Bold is used for java tools, bmj (Borland Make for Java), bcj
(Borland Compiler for Java), and compiler options. For example:
javac, bmj, -classpath.
Italics
Italicized words are used for new terms being defined, for book
titles, and occasionally for emphasis.
Keycaps
[]
<>
Table 1.1
Typeface
Meaning
Italics, serif
...
Platform conventions
Item
Meaning
Paths
Home directory
Screen shots
Introduction
1-5
For more information about Borlands developer support services, see our
web site at http://www.borland.com/devsupport/, call Borland Assist at (800)
523-7070, or contact our Sales Department at (831) 431-1064.
When contacting support, be prepared to provide complete information
about your environment, the version of the product you are using, and a
detailed description of the problem.
For support on third-party tools or documentation, contact the vendor of
the tool.
Online resources
You can get information from any of these online sources:
World Wide Web
http://www.borland.com/
FTP
ftp://ftp.borland.com/
Technical documents available by anonymous ftp.
Listserv
1-6
Borland newsgroups
You can register JBuilder and participate in many threaded discussion
groups devoted to JBuilder. The Borland newsgroups provide a means for
the global community of Borland customers to exchange tips and
techniques about Borland products and related tools and technologies.
You can find user-supported newsgroups for JBuilder and other Borland
products at http://www.borland.com/newsgroups/.
Usenet newsgroups
The following Usenet groups are devoted to Java and related
programming issues:
Note
news:comp.lang.java.advocacy
news:comp.lang.java.announce
news:comp.lang.java.beans
news:comp.lang.java.databases
news:comp.lang.java.gui
news:comp.lang.java.help
news:comp.lang.java.machine
news:comp.lang.java.programmer
news:comp.lang.java.security
news:comp.lang.java.softwaretools
These newsgroups are maintained by users and are not official Borland
sites.
Reporting bugs
If you find what you think may be a bug in the software, please report it in
the Support Programs page at http://www.borland.com/devsupport/namerica/.
Click the Reporting Defects link to bring up the Entry Form.
When you report a bug, please include all the steps needed to reproduce
the bug, including any special environmental settings you used and other
programs you were using with JBuilder. Please be specific about the
expected behavior versus what actually happened.
If you have comments (compliments, suggestions, or issues) for the
JBuilder documentation team, you may email [email protected]. This is
for documentation issues only. Please note that you must address support
issues to developer support.
JBuilder is made by developers for developers. We really value your
input.
Introduction
1-7
1-8
Chapter
Chapter2
Web Development is a
feature of JBuilder
Enterprise. Applet
development is a feature
of all editions of JBuilder
Technology
Description
Servlets
InternetBeans Express
Struts
2-1
Servlets
Table 2.1
Technology
Description
Cocoon
Applets
The summary gives you some idea about the nature of each of these
technologies, but how do you know which ones to use? What are the
advantages and disadvantages of each of these technologies? Well
answer these questions and more in the following discussion.
Servlets
Servlets are Java programs that integrate with a web server to provide
server-side processing of requests from a client browser. They require a
web server that supports JavaServer technology, such as the Tomcat web
server that ships with JBuilder. (Tomcat can also be integrated with web
servers that dont support JavaServer technology, thus allowing them to
do so. One example of this is IIS.) Java servlets can be used to replace
Common Gateway Interface (CGI) programs, or used in the same
situations where you might have previously used CGI. There are some
advantages to using servlets over CGI:
Reduced memory overhead
Platform independence
Protocol independence
You use a client program written in any language to send requests to the
servlet. The client can be as simple as an HTML page. You could also use
an applet for the client, or a program written in a language other than
Java. On the server side, the servlet processes the request, and generates
dynamic output which is sent back to the client. Servlets usually dont
have a UI, but you can optionally provide one on the client side.
2-2
2-3
JSTL 1.0: A tag library provided by Sun that includes a set of tags to
allow developers to do common tasks in a standard way.
Struts 1.0: An open source tag library provided by the Jakarta Project
that is used for building web applications.
Note
You can also define your own tag libraries and use them in JBuilder.
Additionally, third parties may provide more advanced tag library
support or other frameworks through OpenTools.
JSPs have some advantages and some disadvantages compared to
servlets. These are some of the advantages:
Less code to write.
Easy to incorporate existing JavaBeans.
Deployment is easier. More of the deployment issues are automatically
taken care of for you, because JSPs map to a web server in the same way
that HTML files do.
You can use tags only, and dont need to embed HTML code in your
JSP. This means that page authors dont have to know Java at all. (Of
course, you can still embed HTML code in your JSP. With careful
planning, the HTML code can be cleanly separated from the Java code,
making the JSP more readable.)
These are some of the disadvantages of JSPs:
Invisible generated servlet code can be confusing, as previously
mentioned.
Since the HTML and Java are not in separate files, a Java developer and
a web designer working together on an application must be careful not
to overwrite each others changes.
The combined HTML and Java in one file can be hard to read, and this
problem intensifies if you dont adhere to careful and elegant coding
practices.
The JBuilder designer does not support designing .jsp files.
JSPs are very similar to ASPs (Active Server Pages) on the Microsoft
platform. The main differences between JSPs and ASPs are that the objects
being manipulated by the JSP are JavaBeans, which are platform
independent. Objects being manipulated by the ASP are COM objects,
which ties ASPs completely to the Microsoft platform.
For more information on JSP technology, see Chapter 6, Developing
JavaServer Pages.
2-4
InternetBeans Express
InternetBeans Express
JBuilders InternetBeans Express technology integrates with servlet and
JSP technology to add value to your application and simplify servlet and
JSP development tasks. InternetBeans Express is a set of components and
a JSP tag library for generating and responding to the presentation layer of
a web application. It takes static template pages, inserts dynamic content
from a live data model, and presents them to the client; then it writes any
changes that are posted from the client back into the data model. This
makes it easier to create data-aware servlets and JSPs.
InternetBeans Express contains built-in support for DataExpress DataSets
and DataModules. It can also be used with generic data models and EJBs.
For more information on InternetBeans Express, see Chapter 7, Using
InternetBeans Express.
Struts
The Struts open source framework is based on the Model 2, or ModelView Controller, approach to software design. In this framework, the
model contains the data, the view is the presentation of the data, and the
controller controls the interaction between the model and the view.
The view is typically a JSP page.
The model can be any data access technology, from JDBC to an EJB.
The controller is a Struts servlet called ActionServlet.
This framework, which is a collection of classes, servlets, JSP tags, a tag
library, and utility classes, cleanly divides the HTML from the Java code
and the visual presentation from the business logic.
The major advantage of using Struts is the division between Java code and
HTML tags. With Struts, your web application becomes easier to
understand. A web designer doesnt have to search through Java code to
make changes to the presentation, and a developer doesnt have to
recompile code when redesigning the flow of the application.
Other than its complexity, the Struts framework provides few
disadvantages for the Java developer. JBuilder provides a robust set of
tools that simplify the complexity and help keep classes and xml files in
sync.
For more information about Struts in JBuilder, see Chapter 8, Using the
Struts framework in JBuilder. For more information about Struts, see
The Jakarta Project: Struts at http://jakarta.apache.org/struts/
index.html.
2-5
Applets
There was much ado about applets when the Java language first became
available. Web technology was less developed then, and applets promised
solutions to some of the problems faced by developers at that time. In fact,
applets became so popular that to this day, developing an applet is often
one of the first assignments given in beginning Java courses. As a result, a
common mistake among Java developers is to rely too much on applets.
Applets certainly have their place, but they are not a magic solution to
your web development problems.
Some of the disadvantages of applets are:
Deployment and testing can be difficult.
You are relying on the client machine having Java enabled in its
browser.
Different browsers support different versions of the JDK, and usually
not the latest version.
The applet can be slow to start the first time, because it needs to be
downloaded by the client.
Some of these problems do have solutions, which are discussed in more
detail in Chapter 14, Working with applets. When considering using an
applet, it is best to think about whether some other Java technology can
better serve your purposes.
2-6
2-7
If you need a complex UI, but you also want some of the features of
servlets or JSPs, consider combining an applet and a servlet. You can
have an applet on the browser (client) side talk to a servlet on the server
side.
If you want to use a servlet or JSP, and you want to make it data-aware,
you should use InternetBeans Express.
If youre thinking of developing a tag library of standard routines, such
as control structures or date and number formatting, look at JSTL first
to see if it already has the routines you need.
If you want to separate the HTML from the Java code, use a Struts web
application.
Note that servlets and JSPs are similar enough that deciding between
them is largely a matter of personal preference. Also, keep in mind that
many web applications will use some combination of two or more of these
technologies.
2-8
Step
Description
Design your
application
Configure your
web server in the
JBuilder IDE
Develop your
application
Compile your
application
Step
Description
Deploy your
application
Test your
application
2-9
2-10
Chapter
Chapter3
Web Development is a
feature of JBuilder
Enterprise
The WebApp
A WebApp describes the structure for a web application. It is essentially a
directory tree containing web content used in your application. It maps to
a ServletContext. A deployment descriptor file called web.xml is always
associated with each WebApp. This deployment descriptor contains the
information you need to provide to your web server when you deploy
your application.
Using a WebApp is required if you have servlets or JSPs in your project.
Although you probably wouldnt use a WebApp if your web application
contains only an applet, you must use one in a web application which
contains an applet and a servlet or JSP. That way, you can store the whole
WebApp in a single WAR file. You might have several WebApps in one
web site. JBuilder supports this notion by allowing you to have multiple
WebApps in one project.
3-1
Its important to think about the structure of your web applications during
the planning stages. How many WebApps does it have? What are their
names? Will you store these WebApps in WAR files? Do your WebApps
require any framework support? By planning the structure from the
beginning, you make deployment easier later on. JBuilder does support
the notion of a default WebApp, rooted in the <projectdirectory>/
defaultroot directory. If you dont specify WebApps for your web
applications, they go into the default WebApp.
For more information on how JBuilder works with WebApps, see
Creating a WebApp with the Web Application wizard on page 3-3, and
The WebApp and its properties on page 3-5.
3-2
Tool
Description
Web Application
wizard
WebApp node
Table 3.1
Tool
Description
WebApp DD Editor
3-3
7 Specify a default Launch URI, if desired. This field might be filled in for
you, if the selected framework supports a default launch URI. For
example, if you choose the Cocoon framework, the Launch URI is set to
index.xml. If a Launch URI is specified, the Web Run, Web Debug, and
Web Optimize commands are available on the context menu for the
WebApp node in the project pane.
8 Click OK to close the wizard and create the WebApp.
Figure 3.1
You can also use the Web Application wizard to import an existing web
application. Fill in the Name field and use the Directory field to point to
the location of the directory containing your existing web application. If
3-4
the web application is valid and the deployment descriptor(s) are correct
for the currently configured web server, it can be run from within the
JBuilder IDE immediately.
The WebApp node has two or three child nodes; a Root Directory for the
application, a Deployment Descriptors node representing the WEB-INF
directory for the WebApp, and an optional WAR file node.
You should place web content files (such as HTML, SHTML, and JSP files)
in the WebApps root directory or one of its subdirectories. Web content
files are files which can be accessed directly by the client browser. Java
resources used by the WebApp (such as servlets or JavaBeans) should
have their source files in the source directory for the project. These files
are not directly accessible by the client browser, but are called by
something else, such as a JSP file. JBuilders Servlet wizard, JSP wizard,
and Web Start Launcher wizard make it easy to create web applications
that follow these rules. Make sure to specify an existing WebApp when
using these wizards.
Root directory
The root directory defines the base location for the web application. Every
part of the web application will be located relative to the root directory.
Web content files, such as HTML, SHTML, JSP, or image files, should be
placed in this directory. Web content files are files which can be accessed
directly by the client browser.
3-5
The files in the WebApps root directory (and any subdirectories of the
root directory) are automatically displayed in the Root Directory node of
the project pane. Only files of the types you specify on the WebApp page
of the WebApp Properties dialog box are displayed. The default file types
are the ones you typically work with in a web application. This allows you
to work with HTML files or image files using your favorite tools for
working with those file types. Save these files in the WebApps root
directory, or one of its subdirectories. Then just click the project panes
Refresh button to see the current file set in JBuilder.
Deployment descriptors
Each WebApp must have a WEB-INF directory. This directory contains
information needed by the web server when the application is deployed.
This information is in the form of deployment descriptor files. These files
have .xml extensions. They are shown in the Deployment Descriptors node
in the project pane. The WEB-INF directory is actually a subdirectory of your
WebApps root directory. It isnt shown under the Root Directory node of
the project pane because it is a protected directory that cannot be served
by the web server. You can change this with the Directories page of the
WebApp Properties dialog box.
The WebApps Deployment Descriptors node always contains a
deployment descriptor file called web.xml. This is required by all Javaenabled web servers and is created by JBuilder when you create the
WebApp. If you are using the Struts framework in your WebApp, the
struts-config.xml file will also be located in the Deployment Descriptors
node.
Your web server may also require additional deployment descriptors
which are unique to that particular web server. These can be edited in
JBuilder and are created if they are listed as required by the currently
configured web server plug-in. Check your web servers documentation
to find out which deployment descriptors it requires.
JBuilder provides a deployment descriptor editor for editing the web.xml
file. You can also edit server-specific deployment descriptors in JBuilder.
Some mappings in the web.xml file are required for the WebApp to work as
desired within the JBuilder IDE. These mappings will be written for you
when you use JBuilders wizards to create the pieces of your web
application. Other mappings may be required when you deploy your
application. For more information on deployment descriptors and the
WebApp DD Editor, see Editing deployment descriptors on page 11-4.
3-6
WebApp properties
The WebApp node in the project pane has various properties you can edit.
To edit the WebApp nodes properties, right-click the node and select
Properties from the menu. The WebApp Properties dialog box has five
pages:
WebApp
Directories
Classes
Dependencies
Manifest
3-7
is not shown in the drop-down list, click the ellipsis (...) button to browse
to it.
Figure 3.3
See also
Creating a WebApp with the Web Application wizard on page 3-3
Presenting XML documents in the XML Developers Guide
Chapter 7, Using InternetBeans Express
Chapter 8, Using the Struts framework in JBuilder
Using the Configure Libraries dialog box to manage userdefined frameworks on page 6-6
3-8
3-9
1 Choose one of these options for Classes. If you choose Specified Only or
Specified And Dependent, you must add the classes with the Add
Classes button.
Specified Only
Specified And Dependent
All
3-10
If you select All for both Classes and Resources, every class file in your
output path is included in the WAR file. This may mean that class files
and resources will be included which are not necessary. Be aware that
generating a WAR with these settings could take some time and
become very large.
If you dont want to include any dependencies in your archive and only
specified resources, you would choose Specified Only for both Classes
and Resources and then add the classes and resources you want with
the Add Classes and Add Files buttons. To add classes and files, classes
must be on the project output path and files must be on the project
source path.
4 Choose the Add Files button if you selected Specified Only in the
Resources category. Then select the files to add to your archive. The
files must be on the project source path. They will be copied to their
corresponding location in WEB-INF/classes. For example, /myproject/src/
com/whatever/whatever.properties is copied to /WEB-INF/classes/com/
whatever/whatever.properties.
Note
The Add Files dialog box cant look inside archive files. If a file or
package you need is inside an archive file, extract it first to your source
folder, then add it using the Add Files button.
Figure 3.5
3-11
3-12
3-13
Figure 3.8
The WAR file node has a Properties dialog box, accessible by rightclicking the node and selecting Properties. In the Properties dialog box,
you can specify whether the WAR file is considered a Java resource. This
is the same Resource page which is available in the Build Properties dialog
box for all non-Java file types. For more information on Resource
properties, see the Resource section of the online Help topic Build page
(Project Properties dialog box). Note that the more important properties
for the WAR file are found on the WebApp page of the WebApp
Properties dialog box.
Figure 3.9
3-14
To have JBuilder create a WAR file for your web application, first you
must have a WebApp node in your project. You can create this WebApp
with the Web Application wizard, available in the object gallery, or you
can use the default WebApp.
You can tell JBuilder to automatically create or update a WAR file
whenever the project is built, whenever the WebApp is built, both, or
neither. To change the WebApps WAR file settings,
1 Right-click the WebApp node in the project pane and select Properties
from the menu.
2 Click the WebApp tab of the WebApp Properties dialog box.
3 Select the desired Build option from the drop-down list. The following
Build choices are available.
When Building Project Or WebApp
When Building WebApp Only
When Building Project Only
Never
4 Verify that the name and location of your desired WAR file is correct.
You have the option to compress the WAR file if you wish.
Now that you have a WAR file associated with your WebApp, keep in
mind that the various pieces of your web application must be associated
with that WebApp to be added to the WAR file. Many of the wizards have
a WebApp drop-down list for you to select your WebApp when creating
these pieces.
3-15
3-16
Chapter
Chapter4
Web Development is a
feature of JBuilder
Enterprise
Note
4-1
4-2
4-3
commonly used classes and interfaces in the servlet package and provides
a brief description of each.
Table 4.1
Name
Class or
Interface
Description
GenericServlet
Class
RequestDispatcher
Interface
Servlet
Interface
ServletConfig
Interface
ServletContext
Interface
ServletException
Class
ServletInputStream
Class
ServletOutputStream
Class
ServletRequest
Interface
ServletResponse
Interface
SingleThreadModel
Interface
UnavailableException
Class
4-4
GET
POST
PUT
DELETE
HEAD
TRACE
CONNECT
OPTIONS
Name
Class or
Interface
Cookie
Class
HttpServlet
Class
HttpServletRequest
Interface
HttpServletResponse
Interface
HttpSession
Interface
HttpSessionBindingEvent
Class
HttpSessionBindingListener Interface
Description
4-5
Destroying a servlet
A servlet engine does not keep a servlet loaded for any specified period of
time or for the life of the server. Servlet engines can retire servlets at any
4-6
Servlet-aware HTML
time. Because of this, you should program your servlet so that it does not
store state information. To release resources, use the destroy() method.
Servlet-aware HTML
Servlets can easily generate HTML-formatted text, allowing you to use
servlets to dynamically generate or modify HTML pages. With servlet
technology, you do not need to use scripting languages. For example, you
can use servlets to personalize a users experience on a web site by
continually modifying the same HTML page.
If your web server has server-side include (SSI) functionality, you can use
the <servlet> tag to preprocess web pages. This tag must be in a file with
an .shtml extension. The <servlet> tag tells the web server that a preconfigured servlet should be loaded and initialized with the given set of
configuration parameters. The output from the servlet is included in an
HTML-formatted response. Like an <applet> tag, you can also use the class
and codebase attributes to specify the servlets locations.
An example of a <servlet> tag is as follows:
<servlet>
codebase=""
code="dbServlet.Servlet1.class"
param1=in
param2=out
</servlet>
HTTP-specific servlets
Servlets used with HTTP protocol (by extending HTTPServlet) may support
any HTTP method. They can redirect requests to other locations and send
HTTP-specific error messages. Additionally, they can access parameters
which were passed through standard HTML forms, including the HTTP
method to be performed and the URI that identifies the destination of the
request:
String
String
String
String
String
String
method
uri
name
phone
address
city
=
=
=
=
=
=
request.getMethod();
request.getRequestURI();
request.getParameter("name");
request.getParameter("phone");
request.getParameter("address");
request.getParameter("city");
4-7
Deploying servlets
Servlets can be deployed stand-alone to a production web server. They
can also be deployed as a J2EE module. A J2EE module consists of one or
more J2EE components of the same type (web, EJB, client etc.) that share a
single deployment descriptor.
For more information and deployment tips, see Chapter 11, Deploying
your web application.
4-8
Chapter
Chapter5
Web Development is a
feature of JBuilder
Enterprise
In JBuilder Enterprise, you can use the Servlet wizard to create a Java file
that extends javax.servlet.http.HttpServlet. The JBuilder Servlet wizard
creates servlets that generate the following content types:
HTML HyperText Markup Language.
XHTML a reformulation of HTML 4.0 as an application of XML.
WML Wireless Markup Language.
XML eXtensible Markup Language.
With the Servlet wizard, you can also create standard servlets, filter
servlets, or listener servlets (if your web server supports the Java Servlets
v2.3 specification).
5-1
These options are only available if your web server supports the Java
Servlets v2.3 specifications. (Tomcat 4.x is the reference implementation of
these specifications.) Otherwise a standard servlet is created by default.
Table 5.1
5-2
Servlet Type
Description
Standard Servlet
Filter Servlet
Listener Servlet
Figure 5.1
5-3
Similar text is added to the top of the SHTML file, if it was generated.
WML Wireless Markup Language. WML files are regular text files
containing XML content. Due to the restricted bandwidth and memory
capacity of the mobile devices, this content has to be compiled into
compact binary form before it can be presented on a Wireless
Application Protocol (WAP) enabled device.
For WML servlets, only a .java class file is generated. There is no option
for an SHTML file with a WML-type servlet. The .java class file
contains a line of code indicating that the DOC TYPE is WML and the
CONTENT TYPE is WAP. It looks like this:
private static final String CONTENT_TYPE = "text/vns.wap.wml";
private static final String DOC_TYPE = "<!DOCTYPE wml
PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\"\n" +
" \"http://www.wapforum.org/DTD/wml12.dtd\">";
5-4
The servlets doGet() method is modified from the HTML version with
the following code:
out.println("<?xml version=\"1.0\"?>");
if (DOC_TYPE != null) {
out.println(DOC_TYPE);
}
5-5
can change these names to any other name, except an invalid one. For
example, you could have the URL pattern /myhtmlfile.html run the servlet
named custlist which is actually the class package.subpackage.CustomerList.
The entry in the Name field is the name used to identify the servlet in the
web.xml file. The name is displayed in the Servlets node in the structure
pane for the web.xml file. It is also used to map the URL pattern to the
servlet. The URL pattern maps explicitly to a servlet via the servlet name
there is no implicit mapping between the servlet name and the URL.
For example, the following URL:
http://localhost:8080/guestbook/formservlet
generates the following URI (the URI remains after the protocol,
hostname, and port number are removed from the URL):
/guestbook/formservlet
The beginning of the URI is matched against all known WebApp names. A
match causes the remaining part of the URI to be directed to that
particular WebApp/context.
Note
Warning
URL mappings will not be generated if you press the Finish button on one
of the previous wizard steps. You must use the Enter WebApp Details
page to generate a URL mapping.
Figure 5.3
5-7
For filter servlets, you can choose how the servlet is mapped; it can be
mapped with either the URL Pattern or the Mapped Servlet option.
The Mapped Servlet drop-down list allows you to choose another servlet
in your project that is filtered by this servlet. (This field defaults to the
lowercase name of the first servlet in your project, preceded by a forward
slash. For example, if your project already contains Servlet1.java and
Servlet2.java which are both standard servlets, the Mapped Servlet field
would default to servlet1.) The drop-down list shows, in alphabetical
order, all other servlets in the project that have been previously mapped.
If there are none, the option is disabled.
Figure 5.4
5-8
Figure 5.5
5-9
5-10
Invoking servlets
Invoking servlets
Invoking a servlet from a browser window
A servlet can be called directly by typing its URL into a browsers location
field. However, this only works when the web server has a server-invoker
servlet (a servlet whose only purpose is to run other servlets). Tomcat has
an invoker servlet, but many other servers do not. Using an invoker
servlet is not recommended because it is not portable.
If you choose to use an invoker servlet, The general form of the servlet
URL, where servlet-class-name corresponds to the class name of the servlet,
is:
http://machine-name:port-number/servlet/servlet-class-name
For example, a URL in the format of any of the following examples should
enable you to run a servlet:
http://localhost:8080/servlet/Servlet1 (running locally on your
computer)
http://www.borland.com/servlet/Servlet1 (running from this URL)
http://127.0.0.1/servlet/Servlet1 (running from this IP address)
Note
If you omit the port number, the HTTP protocol defaults to port 80. The
first URL in the example above would work in the IDE if you set the
runtime configurations port to 80 and youre not already running a web
server on this port. The other examples would work in a real-life situation,
after the web application had been deployed to a web server.
Servlet URLs can contain queries for HTTP GET requests. For example,
the servlet in Chapter 16, Tutorial: Creating a simple servlet, can be run
by entering the following URL for the servlet:
http://localhost:8080/servlet/simpleservlet.Servlet1?userName=Mary
For more information on how servlets are run, see How URLs run
servlets on page 10-9.
5-11
Internationalizing servlets
HTML pages can also use the following tags to invoke servlets:
A <form> tag
<form action="http://localhost:8080/servlet1 method="post">
A meta tag that uses a servlet URL as part of the value of the http-equiv
attribute.
<meta http-equiv="refresh" content="4;url=http://localhost:8080/servlet1">
Note that you can substitute the servlets fully qualified class name for the
URL pattern. For example, if the servlet class name is Servlet1, you can use
the following <form> tag to run the servlet:
<form action="http://localhost:8080/servlet/simpleservlet.Servlet1" method="post">
Internationalizing servlets
Servlets present an interesting internationalization problem. Because the
servlet outputs HTML source to the client, if that HTML contains
characters that are not in the character set supported by the server on
which the servlet is running, the characters may not be readable on the
clients browser. For example, if the servers encoding is set to ISO-8859-1,
but the HTML written out by the servlet contains double-byte characters,
those characters will not appear correctly on the clients browser, even if
the browser is set correctly to view them.
By specifying an encoding in the servlet, the servlet can be deployed on
any server without having to know that servers encoding setting. Servlets
can also respond to user input and write out HTML for a selected
language.
5-12
5-13
5-14
Chapter
Chapter6
Web Development is a
feature of JBuilder
Enterprise
6-1
6-2
JSP tags
JSP tags
A JSP usually includes a number of specialized tags which contain Java
code or Java code fragments. Here is a list of a few of the most important
JSP tags:
Table 6.1
tag syntax
description
The JSP specification also includes standard tags for bean use and
manipulation. The useBean tag creates an instance of a specific JavaBeans
class. If the instance already exists, it is retrieved. Otherwise, it is created.
The setProperty and getProperty tags let you manipulate properties of the
given bean. These tags and others are described in more detail in the JSP
specification and user guide, which can be found at
http://java.sun.com/products/jsp/techinfo.html.
Its important to realize that most Java code contained within JSP tags
becomes part of the servlets service() method when the JSP is compiled
into a servlet. This doesnt include code contained in declaration tags,
which become complete method or variable declarations in their own
right. The service() method is called whenever the client does a GET or a
POST.
6-3
See also
Working with JSP tag libraries and frameworks in JBuilder on
page 6-5
Chapter 8, Using the Struts framework in JBuilder
Chapter 7, Using InternetBeans Express
6-4
JSPs in JBuilder
JSPs in JBuilder
JBuilder provides a complete development system for JSPs. Heres a list of
JBuilders JSP development features.
A JSP wizard for creating a new JSP that can optionally support one or
more frameworks
JSP tag library and framework support
CodeInsight for completing JSP-specific tags
Debugging within the JSP file
Testing and running the JSP on any JSP-supporting servlet engine from
within the JBuilder development environment
Note
You cant open a JSP in JBuilders designer because it isnt a .java file.
See also
Creating a WebApp with the Web Application wizard on page 3-3
Creating a JSP using the JSP wizard on page 6-10
Using the Configure Libraries dialog box to manage
user-defined frameworks on page 6-6
6-5
JSPs in JBuilder
Struts
JSTL
InternetBeans Express
Cocoon
6-6
JSPs in JBuilder
3 Enter the tab librarys name in the Name field. Choose its location from
the Location drop-down list.
4 Click Add to add the JAR file(s) containing your tag library. Browse to
each JAR file, select it, and click OK.
5 Click OK to close the New Library wizard. The Configure Libraries
dialog box is redisplayed. The new library is displayed in the assigned
folder on the left of the dialog box.
6 Click the Framework tab on the Configure Libraries dialog box.
7 Choose User-Defined JSP Tag Library from the Framework drop-down
list.
8 Click the Add button to display the Define New Tag Library dialog box.
9 Click the ellipsis (...) button next to the TLD File field to browse to the
TLD file you want to define for your tag library. The TLD can be an
external file distributed with the JAR, inside the JAR, or both. The TLD
file must have a .TLD extension. It requires that actual tag handler
classes be in a JAR file. Once you choose a valid TLD file, the Name,
Prefix, URI and Location are automatically filled in for you from the
TLD definition.
10 Click OK to close the Define New Tag library dialog box.
11 Click OK again to close the Configure Libraries dialog box.
Note
6-7
JSPs in JBuilder
If the JSP Tag Libraries tab is not displayed, it means the selected
framework either does not contain JSP Tag Libraries or else they are not
editable.
5 Click the Edit button. The Edit Tag Library dialog box is displayed.
6 Change the TLD File, Name, Prefix, URI, or Location and click OK.
7 Click OK again to save your changes and close the Configure Libraries
dialog box.
Note
6-8
If the JSP Tag Libraries tab is not displayed, it means the selected
framework either does not contain JSP Tag Libraries or else they are not
editable.
JSPs in JBuilder
5 Click Remove.
6 If you want to remove the entire library, choose the library in the left
side of the dialog box and choose the Delete on the lower left.
7 Click OK to close the Configure Libraries dialog box.
Developing a JSP
The JSP wizard is an optional starting point for developing a JSP. JBuilders
editor provides syntax highlighting for JSPs. JBuilder also provides
CodeInsight and ErrorInsight for Java code embedded in a JSP page.
The structure pane in the JBuilder IDE shows the tag structure within the
JSP, and it also shows any HTML and Java errors in your code. These
errors are very useful, for instance, they can often remind you to finish a
tag that was incomplete.
See also
JSP wizard in the online help
Chapter 18, Tutorial: Creating a JSP using the JSP wizard
6-9
JSPs in JBuilder
1 Select File|New to open the object gallery. Click the Web tab. (Your
project must first have a server enabled.)
2 Select JavaServer Page. Click OK.
3 Select a WebApp to contain the new JSP. If you have only one WebApp
in your project, the WebApp drop-down list is disabled.
4 Specify whether to create a sample bean and an error page.
If Generate Sample Bean is checked, the wizard creates a sample
JavaBean that can be used by the JSP. Checking this option adds a
step to the wizard.
If Generate Error Page is checked, the wizard creates an error page
that displays runtime errors in a tidy and useful way. Checking this
option adds a step to the wizard.
Click Next to go to the next step. You may also click Finish to skip the
remaining steps, close the wizard, and create the JSP.
8 Specify the Package and Class Name for the sample bean. Check
Generate Header Comments if you want header comments to be
generated in the sample bean. If you didnt check Generate Sample
Bean in the first step of the wizard, you wont see this step.
Click Next to go to the next step. You may also click Finish to skip the
remaining steps, close the wizard, and create the JSP.
6-10
JSPs in JBuilder
9 Use the Add Bean and Remove Bean buttons to specify JavaBeans
youd like the JSP to use. The wizard generates a jsp:useBean tag for
each JavaBean specified.
When youre finished specifying JavaBeans, click Next to go to the next
step. You may also click Finish to skip the remaining steps, close the
wizard, and create the JSP. If you didnt check Generate Sample Bean or
Generate Error Page in the first step of the wizard, there are no other
steps and the Next button is disabled.
10 Specify a Name and the background color for the error page. If you
didnt check Generate Error Page in the first step of the wizard, you
wont see this step.
Click Next to go to the next step. You may also click Finish to skip the
remaining step, close the wizard, and create the JSP.
See also
JSP wizard in the online help
Chapter 18, Tutorial: Creating a JSP using the JSP wizard
Using the Configure Libraries dialog box to manage
user-defined frameworks on page 6-6
Working with JSP tag libraries and frameworks in JBuilder on
page 6-5
Chapter 8, Using the Struts framework in JBuilder
Chapter 7, Using InternetBeans Express
Compiling a JSP
JSPs are an extension of the Servlet API and are compiled to servlets
before they are used. This requires the compilation process to translate JSP
file names and line numbers into their Java equivalents. In JBuilder, JSPs
can be compiled at build-time. To enable this feature for all JSPs in your
project,
6-11
JSPs in JBuilder
Deploying a JSP
See Chapter 11, Deploying your web application, for tips on deploying
your JSP.
6-12
6-13
6-14
Chapter
Chapter7
Web Development is a
feature of JBuilder
Enterprise
7-1
Component type
Description
IxPageProducer
IxControl
IxTable
IxImage
IxLink
IxSpan
IxCheckBox
IxComboBox
IxHidden
7-2
IxImageButton
IxListBox
Table 7.1
Component type
Description
IxPassword
IxPushButton
IxRadioButton
IxSubmitButton
IxTextArea
IxTextField
7-3
For example, when using InternetBeans Express with a servlet, you can
open the servlet in the designer. A Database and QueryDataSet from the
DataExpress tab of the palette can provide the data for the servlet. You can
add an IxPageProducer from the InternetBeans tab of the palette. Set the
IxPageProducers htmlFile property to the file name of the pre-designed
web page. When the servlet is run, the internal HtmlParser is invoked by
the IxPageProducer to locate all replaceable HTML controls.
The simplest way to replace HTML controls with controls containing
dynamically generated data is to use IxControls. You should add one
IxControl for each HTML control on the template page which will contain
data. Set each IxControls pageProducer property to the IxPageProducer. Set
the IxControls controlName property to match the name attribute of the
appropriate HTML control. Setting the dataSet and columnName properties of
the IxControl completes the data linkage.
The IxPageProducer.servletGet() method is the one you will normally call
to generate the page for display. This method should be called within the
servlets doGet() method. The body of a servlets doGet() method can often
be as simple as:
ixPageProducer1.servletGet(this, request, response);
This single call sets the content type of the response and renders the
dynamic page into the output stream writer from the response. Note that
the default content type of the response is HTML.
Internally, the IxPageProducer.render() method generates the dynamic
version of the page, replacing the controls that have an IxControl assigned
to them by asking the component to render, which generates equivalent
HTML with the data value filled in from the current row in the dataset.
You could call the render() method yourself, but it is simpler to call the
servletGet() method.
Some situations where you wouldnt use an IxPageProducer in a servlet
include:
When you dont need the database session management and posting
features of the IxPageProducer and simply want the page template
engine, you can use the PageProducer instead.
When youre using specific individual components to render HTML.
For example, you can create an IxComboBox containing a list of countries,
and use it in a servlet with hand-coded HTML.
Remember that when using InternetBeans in a servlet, usually you should
use an IxPageProducer. When you are using IxControls, you must use an
IxPageProducer.
7-4
This method should be called within the servlets doPost() method, along
with any other code that should be executed during the post operation.
At design-time, you should add an IxSubmitButton for each Submit button
on the form. Add a submitPerformed() listener for each of the
IxSubmitButtons. The listener should call code that is to be executed when
the button is pressed. For example, a Next button should do
dataSet.next(), and a Previous button should do dataSet.prior().
At runtime, when the servletPost() method is called it writes the new
values from the post into the corresponding InternetBeans components
and transmits those values from the client side to the server side. It then
fires the appropriate submitPerformed() event for the button that submitted
the form. To actually post and save changes to the underlying dataset, you
should call the datasets post() and saveChanges() methods within the
submitPerformed() method. The servlets doPost() method can then call
doGet() or call IxPageProducer.servletGet() directly to render the new page.
Parsing pages
Unlike XML, which is strict, the HTML parser is lax. In particular, HTML
elements (tag) and attribute names are not case-sensitive. However,
XHTML is case-sensitive; the standard names are lowercase by definition.
To make things faster, HTML element and attribute names are converted
to the XHTML-standard lowercase for storage. When searching for a
particular attribute, use lowercase.
When InternetBeans Express components are matched with HTML
controls in the page, properties set in the InternetBeans Express
component take precedence. When setting properties in the designer, you
should think about whether you actually want to override a particular
HTML attribute by setting its corresponding property in the component.
For example, if the web page contains a textarea of a certain size, you
probably dont want to override that size when that control is dynamically
generated.
7-5
Generating tables
A fairly common and complex task is the display of data in a table using a
particular format. For example, there may be certain cell groupings and
alternating colors for each row.
The web page designer need only provide enough dummy rows to
present the look of the table (for alternating colors, thats two rows). When
the replacement table is generated by the IxTable component, that look
will be repeated automatically.
You can set cell renderers by class or assign each column its own
IxTableCellRenderer to allow customization of the content; for example,
negative values can be made red (preferably by setting an appropriate
cascading style sheets (CSS) style, not by hard-coding the color red).
For a tutorial on using InternetBeans in a servlet, see Chapter 19,
Tutorial: Creating a servlet with InternetBeans Express.
If you want to instantiate classes in your scriptlets, and dont want to type
the fully-qualified class name, you can import files or packages into your
JSP using a page directive. This page directive can specify that the
com.borland.internetbeans package should be imported into the JSP. The
page directive should look something like this:
<%@ page import="com.borland.internetbeans.*,com.borland.dx.dataset.*,
com.borland.dx.sql.dataset.*" %>
Remember that directives such as the taglib directive and the page
directive must always be the very first lines in your JSP.
JBuilders JSP wizard inserts a taglib directive and a page directive for you
if you select the internetbeans tag library in the Edit JSP File Details step of
7-6
the wizard. The JSP wizard also completes the other necessary steps for
setting up your JSP to use InternetBeans Express. These steps are as
follows:
Here is an example of how an InternetBeans tag looks when used in your JSP:
<ix:database id="database1"
driver="com.borland.datastore.jdbc.DataStoreDriver"
url="jdbc:borland:dslocal:..\\guestbook\\guestbook.jds"
username="user">
</ix:database>
This example uses the database tag. If you were actually using the database
tag in a JSP, in most cases you will want to nest other tags within this tag,
such as the query tag. This isnt required, but it makes the JSP code more
readable.
Note
The ix prefix could be any text. It all depends on what prefix is specified in
the taglib directive. The JSP wizard uses the ix prefix for the internetbeans
tag library.
For a tutorial on this topic, see Chapter 20, Tutorial: Creating a JSP with
InternetBeans Express.
7-7
7-8
Tag name
Description
Attributes
database
Defines a
DataExpress
Database
query
Defines a
DataExpress
QueryDataSet
control
Defines an
InternetBeans
Express
IxControl
image
Defines an
InternetBeans
Express IxImage
submit
Defines an
InternetBeans
Express
IxSubmitButton
table
Defines an
InternetBeans
Express IxTable
There are only six tags in the InternetBeans Express tag library, yet there
are seventeen InternetBeans components. This may seem like a major
limitation, but its really not. The control tag maps to an IxControl, which
delegates to all the other control-specific InternetBeans. The only
InternetBeans which arent covered by the tag library are IxSpan and
IxLink. Neither of these are useful in a JSP, because you can just as easily
use your own JSP expression scriptlet to do the same thing.
Of course, its also possible to use InternetBeans directly, just like any
other bean or Java class. Using the tag library is just much more
convenient and it does a few extra things for you (like maintaining the
session state for data entry).
Format of internetbeans.tld
It is useful to know that you can always look at the source of the
internetbeans.tld file for hints about use of the various tags. To do this,
open it in JBuilders editor. This file cannot (and should not) be modified.
The internetbeans.tld file is available in internetbeans.jar. You dont need
to be able to view the contents of internetbeans.tld in order to use its tags
in your JSP, but if you want to view the internetbeans.tld file in the editor,
you need to do the extra step of adding it to your project. To do this:
1 Click the Add Files/Packages button on the toolbar above the project
pane.
2 In your project directory, find internetbeans.jar. It will be in the WEB-INF/
lib directory of your WebApp.
3 In the directory tree, click to expand the internetbeans.jar node.
4 Under com.borland.internetbeans.taglib, locate the internetbeans.tld file
and select it.
5 Click OK to add the file to your project.
The information at the very top of the internetbeans.tld file is of little
interest. The information that is useful to understand begins with the first
<tag> tag inside the file. Each <tag> tag represents an InternetBeans tag
definition.
7-9
At the beginning of each tag definition, you see a <name> tag which
indicates the name of the tag. The first one is the database tag. Nested
within each tag definition, you will also see <tagclass>, <info>, and
<attribute> tags. For an example of how an InternetBeans tag definition
looks, see the fragment of the internetbeans.tld file which defines the
submit tag below:
<tag>
<name>submit</name>
<tagclass>com.borland.internetbeans.taglib.SubmitTag</tagclass>
<bodycontent>JSP</bodycontent>
<info>Submit button or submit image control</info>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>methodName</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
The <tagclass> tag indicates the name of the class within the
com.borland.internetbeans.taglib package which is responsible for
interpreting this InternetBeans tag when it is used in a JSP. The <info> tag
supplies a description of the InternetBeans tag.
The <attribute> tag describes an attribute for an InternetBeans tag. There is
one <attribute> tag for each attribute. These can be thought of as the
components properties. Nested within the <attribute> tag you will see
these properties. Each property has a name, a boolean value indicating
whether or not it is a required property, and a boolean value indicating
whether or not its value can be set using a java expression. The name is
found within the <name> tag, the <required> tag indicates whether or not the
property is required, and the <rtexprvalue> tag indicates whether or not
the property can be set using a java expression. Those properties which
cant be set using an expression require a literal value.
7-10
Chapter
Chapter8
Web Development is a
feature of JBuilder
Enterprise
8-1
Before
After
JSP File
JSP File
<HTML>
<%Java%>
<HTML>
<JSP Tag>
Service
JSP:Tag
Tag Library
Controller
ActionServlet
Configuration
XML file
Business
Logic
Action
Resource
Properties
file
Model
ActionForm
Service
8-3
Notice how the Struts tag libraries are displayed on the JSP Tag Libraries
tab of the Framework tab.
For more information on libraries in JBuilder and the Configure
Libraries dialog box, see Working with libraries in the Managing
paths chapter of Building Applications with JBuilder.
For more information on JSPs and tag libraries, see Working with JSP
tag libraries and frameworks in JBuilder on page 6-5.
8-4
Note
You can use more than one framework in a web application. For example,
you can use Cocoon, Struts and the JSTL in one WebApp.
Once you choose the Struts framework for your WebApp, JBuilder adds
mappings to the web.xml file and copies or creates files as needed. For the
Struts framework, the *.tld files are copied into the WEB-INF directory and
their mappings are added to web.xml. JBuilder creates the struts-config.xml
file in the WEB-INF directory.
Some web frameworks may declare a standard welcome page that is used
for the URI. In this case, the Launch URI field will be updated
automatically with the name of the welcome page. For example, if you
choose the Cocoon framework, the Launch URI is set to /index.xml.
Once your WebApp has been created, you can change the node
properties, including the framework selection, by right-clicking the
WebApp node in the project pane and choosing Properties. You can
change the framework on the JSP/Servlet Frameworks tab of the WebApp
page.
Important
8-5
You select tag libraries by checking the box next to the tag library you
want to use. You can choose any of the tag libraries; your choice does not
have to be already enabled for your web application.
ActionForm wizard
An ActionForm class contains the session state of a web page. Each ActionForm
bean is a subclass of the ActionForm abstract class. The ActionForm contains
setters and getters for each of the data fields that the ActionForm is responsible
for. This is typically all the fields in an input form on a page, but it can also
span several related pages that act in a wizard-like way. The ActionForm also
contains a validate() method that validates the data that is given to it.
Important
You create an ActionForm class for a JSP. To use this wizard, you must have
a JSP in your project. For information on the sequence of steps required to
create a Struts web application, see Creating a Struts-enabled web
application in JBuilder on page 8-16.
The ActionForm wizard allows you to quickly and easily create an
ActionForm. You can either add fields through the wizard or prepopulate
the fields from an existing JSP page. The wizard creates the ActionForm
class and registers it in the web.xml file.
8-6
Web Application And Class Info For Action Form page ActionForm wizard
8-7
Note
If the ActionForm class name you choose already exists and is a valid
ActionForm, you will be prompted to import the existing fields from the
ActionForm. This is useful for extending an existing form or for building a
form that spans multiple JSPs. If you choose not to import existing fields,
the original file will not be deleted, but all setters and getters will be
removed and replaced with the fields from the final list. Any additional
methods will be preserved. If fields were removed, a warning message
will be displayed reminding you to fix the validate() method.
After you enter all the fields, the wizard will generate the ActionForm and
register it in struts-config.xml.
Action wizard
An Action is the control class in the Struts framework. The Action.perform()
method is called to execute business logic. An ActionForward class is
returned. ActionForward tells the Struts controller servlet the next action in
the chain of events. The Action wizard quickly creates an Action class and
registers it in struts-config.xml.
8-8
You create an Action class for a ActionForm class. To use this wizard, you
must have a JSP and ActionForm class in your project. For information on
the sequence of steps required to create a Struts web application, see
Creating a Struts-enabled web application in JBuilder on page 8-16.
Figure 8.8
8-9
Figure 8.9
8-10
8-11
The file created by the Struts Conversion wizard replaces your original
file. However, you can use JBuilders history view to recover it.
The Struts Conversion wizard is available from the Web page of the object
gallery. It is also available from the editor context menu when a JSP or
HTML file is open. If you choose the wizard from the context menu, the
file to be converted will be listed in the JSP And HTML Files to Convert
list on the first page of the wizard.
8-12
8-13
For more information on the Struts Config Editor, see Chapter 13,
Editing the struts-config.xml file.
8-14
To do this, JBuilder adds the following code to the top of the web.xml
file:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
Note
If the web.xml file already maps a servlet named action, none of these
changes are made.
8-15
c You can click Finish on this page, you do not need to set options on
other pages.
8-16
4 Add Struts-enabled tags to the JSP to design the view. For more
information on building the view layer of the Struts web application,
see Building View Components in the Struts Users Guide at http://
jakarta.apache.org/struts/userGuide. The document also includes
information about building forms with Struts and internationalizing
your Struts web application. It additionally discusses other
presentation techniques, such as includes, tiles (a feature of Struts 1.1),
image rendering components, and text rendering.
Note
If you dont use Struts tags in your JSP, you can use the Struts
Conversion wizard to convert the HTML tags in your JSP to Struts.
8-17
8-18
Chapter
Chapter9
Web Development is a
feature of JBuilder
Enterprise
Both Java servlets and JavaServer Pages (JSP) run inside web servers.
Tomcat, the JavaServer Pages/Java Servlets reference implementation, is
included with JBuilder. Although it might differ from your production
web server, Tomcat allows you to develop and test your servlets and JSPs
within the JBuilder development environment.
JBuilder Enterprise supports the Borland Enterprise Server, Sun iPlanet,
IBM WebSphere and BEA WebLogic application servers. These
application servers contain web servers. However, in order to use the
contained web server, you must have the corresponding application
server installed and configured. You cannot use the web server outside of
its application server container. Once youve configured your web
application and web server, you can compile, run and debug your servlet
and JSP. For more information, see Chapter 10, Working with web
applications in JBuilder.
Note
In JBuilder Enterprise, you can however, use the Tomcat web server as a
stand-alone web server.
9-1
Note
Note
In the tree on the left side of the dialog box, entries in gray have not yet
been configured. Entries in red are invalid.
2 Choose one of the Tomcat installations from the User Home folder. The
Enable Server option at the top of the right side of the dialog box is
automatically checked. You do not need to change any settings.
3 Click OK to close the dialog box.
9-2
If you have installed Tomcat to another directory, and want to run Tomcat
from that directory instead of the default, you can change the settings to
point to that directory. The following table explains the settings.
Table 9.1
Option
Description
Home directory
Main class
VM parameters
Server parameters
Working directory
Class
Source
Documentation
Required Libraries
If youd like more information about Tomcat or would like to run it standalone, refer to the documentation directory of JBuilders Tomcat
installation:
Tomcat 3.3 <jbuilder>/thirdparty/jakarta-tomcat-3.3.1/doc
Tomcat 4.0 <jbuilder>/thirdparty/jakarta-tomcat-4.0.6-LE-jdk14/
webapps/tomcat-docs
Tomcat 4.1 <jbuilder>/thirdparty/jakarta-tomcat-4.1.12-LE-jdk14/
webapps/tomcat-docs
Note
9-3
Important
9-4
Note
1 Select the Single Server For All Services In Project option and
select the server from the drop-down list. This server can either be
an application server that contains a web server or the Tomcat
web server that is installed with JBuilder.
2 If you want to avoid having libraries added to your project that
you wont use, uncheck the check box in front of the service(s)
you dont need in the Services list. If you disable services, the
corresponding JBuilder features will be disabled. For example, if
you turn off the JSP/Servlet service, most of the Web wizards and
the JSP compilation feature are disabled.
3 If you want to make changes to the configuration settings for the
selected server, click the ellipsis button to the right of the server
name and edit the settings you want on the General and/or
Custom pages. Click OK when youre finished.
9-5
9-6
1 Choose the Web tab on the IDE Options dialog box (Tools|IDE
Options). The Web page looks like this:
9-7
3 Choose Web View Options. These options work in conjunction with the
Search For Unused Port option on the Runtime Configuration
Properties dialog box when the specified port is in use by a non-web
process. (See Creating a runtime configuration on page 10-2 for more
information.)
Choose the Launch Separate Process And Use Web View option to
use both the internal web browser and an external web browser. This
option automatically displays your rendered servlet or JSP in the
Web View page of the content pane.
Choose the Use Web View On Running Process If Possible option to
use the internal web browser to view your web page. This option
automatically displays your rendered servlet or JSP in the Web View
page of the content pane. If a web server is already running, JBuilder
uses the same process on the existing port. This is the default.
Choose the Do Not Use Web View Always Launch Separate Process
option when launching your web application in an external web
browser.
9-8
Chapter
10
Working with web applications
in JBuilder
Chapter10
Web Development is a
feature of JBuilder
Enterprise
Note
If you set a Launch URI for a WebApp (in the Web Application wizard),
you can run the WebApp from that specified location from the WebApp
nodes context menu. This way, if your application has an obvious starting
point, you can run, debug, or optimize without having to drill down into
the web content.
When you create a servlet or JSP using JBuilders Servlet or JSP wizard,
the Web Run and Web Debug commands are automatically enabled.
Important
10-1
Before you can run your applet, servlet or JSP, you need to create a
runtime configuration. For servlets not created with the wizard, you also
need to set run properties. Then, once you compile your servlet or JSP,
you can web run it.
When you create an Applet runtime configuration with the wizard, the
Applet runner becomes active. The applet is run in JBuilders applet
viewer, AppletTestbed, using the applet class file. (Note that you cannot
Web Run or Web Debug an applet because it does not launch a server to
run; it runs in a browser. Additionally, applets do not have a web
application context, or WebApp.)
When you create a Servlet runtime configuration with the wizard, the
Server runner becomes active. The server selected in the Project Properties
Server page becomes the active web server. The URI to run is taken from
10-2
the entry in the URL Pattern field on the Enter WebApp Details page of
the Servlet wizard and from the servlets WebApp.
When you create a JSP runtime configuration with the wizard, the Server
runner becomes active. The server selected in the Project Properties Server
page becomes the active web server. The URI to run is taken from the
WebApp and the JSP file name.
10-3
If you run the applet from the HTML page, you dont need to set
parameters since they are already set in the HTML page.
1 Open the Project Properties dialog box and choose the Server tab.
10-5
Important
If you have two different servers in the same project, you will need two
separate runtime configurations, one for each server.
To create a server runtime configuration,
10-6
7 To choose the servlet or JSP to launch, click the ellipsis (...) button to the
right of the Launch URI field. The Type Or Choose URI To Launch
dialog box is displayed. You run the servlet or JSP via a URI so that
focus will switch to the web view when you use the Web Run
command.
You can either directly type the URI (Universal Resource Identifier)
into the URI text field at the top of the dialog box or choose the
WebApp and URI from the trees at the bottom of the dialog box:
a Choose the WebApp of the URI you want to run from the WebApp
drop-down list. This list displays all WebApps that are defined in
your project.
b Choose the URI directly from one of the three different trees at the
bottom of the Launch URI dialog box. These trees roughly
correspond to the different kinds of servlet mappings. The File, or
web content, tree on the left creates URIs that would probably match
either extension mappings (like *.jsp) or not match anything and get
served by the default servlet. The Servlet Mapping tree in the middle
contains URL patterns for exact matches. The Servlet Class tree,
displayed only if the server has a servlet invoker, creates URIs that
would match the servlet invoker. (Tomcat 3.3 and 4.0 have a servlet
invoker; Tomcat 4.1 does not.)
10-7
For more information about URL mappings, see How URLs run
servlets on page 10-9.
Table 10.1
URI trees
Tree Name
Description
File
(HTML, JSP, etc.)
Servlet Mapping
/selectedwebapp/form
All URL pattern values that do not
or
contain wildcards. Allows a user to
invoke a servlet or JSP by name. This
/selectedwebapp/table
value was entered into the
Name/URL Pattern fields on the
Servlet wizard Enter WebApp
Details page.
Servlet Class
/selectedwebapp/hello.html
or
/selectedwebapp/login.jsp
/selectedwebapp/servlet/com.test.MyServlet
If you specify product=1234 in the Query String field, the query gets
added to the end of the URL:
http://localhost:8080/showproduct.jsp?product=1234
http://localhost:8080/saleshistory?product=1234
10-8
The question mark (?) separates the name of the servlet or JSP to run
from the query string. This allows the servlet and JSP to ask for the
parameter product and get back 1234. Note that parameter values are
always strings. Multiple parameters are separated with an ampersand
(&), e.g. product=1234&customer=6789.
10 In the Host Name field, enter the name the web server should assume.
Do not choose a name already in use in your sub-net. localhost is the
default.
11 Enter the port number the web server should listen to in the Port
Number field. Generally, you should use the default port number, 8080.
Change this value only if the default value is in use.
12 Choose the Search For Unused Port option to tell JBuilder to choose
another port if the specified one is in use. It is useful to select this option
when you are running more than one servlet or JSP, as otherwise you
might get a message that the port is busy. It is also useful to check this
option in the event that a user problem brings the web server down.
With this option selected, you are protected if the web server is not shut
down properly. This option works in conjunction with the Launch
options on the IDE Options page when the specified port is in use by a
non-web process. (See Configuring the IDE for web run/debug on
page 9-7 for more information.)
To create a runtime configuration with debug options,
10-9
using the leading slash to indicate the web-root directory. It can then
return the corresponding file, if its there.
Servlet containers like Tomcat and WebLogic are more complex, but more
flexible. These containers allow contexts and mappings, so that your web
application can have any number of named contexts. Each context is
mapped to its own root directory.
The servlet containers first job in evaluating the request-URI-path is to see
if the first part of the path matches a context name. In JBuilder, these are
the WebApp names. During a Web Run, those names are associated with
WebApp root directories. (For more information on WebApps, see The
WebApp on page 3-1.)
If there is a match, the first part of the request-URI-path becomes the
context path. The remaining part of the path, starting with a slash,
becomes the URL-path-to-map. If there is no match, the context path is an
empty string, and the entire request-URI-path is considered the
URL-path-to-map.
For example, for a project with a single WebApp named myprojectwebapp,
the request-URI-path /myprojectwebapp/subpackage/somename.jsp would be
evaluated as follows:
The context path would be /myprojectwebapp.
The URL-path-to-map would be /subpackage/somename.jsp.
However, the request-URI-path /test/subpackage/somename.jsp would not
contain any context path in the evaluation, since the only existing WebApp is
myprojectwebapp. In this case, the context path would be empty and the
URL-path-to-map would be the entire URI: /test/subpackage/somename.jsp
Note that the context configuration is done in a server-specific way.
However, the matching of the URL-path-to-map is done via the
servlet-mapping entries in each contexts standard WebApp deployment
descriptor, the web.xml file. Each servlet-mapping has two parts: a
URL-pattern and a servlet-name.
There are three special kinds of URL-patterns:
Table 10.2
URL patterns
Pattern Type
Note
10-10
Description
Path mapping
Extension mapping
Starts with *.
Default mapping
Only includes /
The three trees at the bottom of the Launch URI dialog box roughly
correspond to the three different kinds of mappings. For specifics on how
these mappings work in the Launch URI dialog box, see Creating a
server runtime configuration on page 10-5.
All other URL-pattern strings are used for exact matches only. When
matching the URL-path-to-map, an exact match is tried first. For example,
if the WebApp somewebapp includes a URL-pattern /test/jspname.jsp, the
corresponding servlet would be used.
If there is no exact match, a path match is attempted, starting with the
longest path. In the default context, the URL-pattern /test/* would be the
first match.
If there is no path match, then an extension match is tried. The
URL-pattern *.jsp would match both of the following two
request-URI-paths: /testwebapp/subpackage/jspname.jsp and
/myprojectwebapp/anyfolder/myjsp.jsp.
Finally, if there is no extension match, the servlet mapped to / (the default
servlet) is used.
Most web servers already have some default mappings, again done in a
server-specific way. For example, *.jsp would be mapped to a servlet by:
10-11
If that was done for the WebApp test, then /test/myservlet would run the
servlet class myproject.MyServlet within the WebApp context test. For
more information on how the Servlet wizard creates a mapping, see
Enter WebApp Details page on page 5-6.
When you Web Run a servlet .java (or .class) file, the servlet invoker is
used if no exact URL-pattern is found for that servlet class. For the
previous example, a web run under the WebApp test would run
/test/myservlet/myproject.MyServlet.
10-12
4 Choose the WebApp to run under from the Run Under Context Path
drop-down list. This path is used when you select the Web Run
command. It is set in the Web Application wizard.
5 Click OK to close the dialog box.
You can set this property for each JSP file in your project, so that you can
exclude certain files from compilation. For example, JSPs that are intended
to be included in other JSPs probably would not compile successfully on
their own, so you would exclude those files.
10-13
10-14
When you Web Run a servlet or JSP using the iPlanet web server, youll
see two new tabs in the message pane. One is for the iPlanet preparation
phase, and shows the command line used to set up the web server. The
other is for output from the web server itself. Both tabs are called iPlanet.
An example of output to the message pane for the Tomcat web server is
displayed below:
Figure 10.1 Tomcat messages
When the Web Run starts, two new tabs are displayed in the content pane:
Web View and Web View Source. Click the tab to open the web view and
the web view source.
Note
Web View and Web View Source tabs will not display if you have selected
the Do Not Use Web View option on the Web page of the IDE Options
dialog box. For more information, see Configuring the IDE for web
run/debug on page 9-7.
Web view
Formatted output is displayed in the web view pane of the content pane.
The generated URL is displayed in the location field at the top of the web
view.
The web view displays the servlet after it has been processed by the
servlet engine. There may be a delay between when the servlet or JSP file
is edited and when the change is shown in the web view. To see the most
recent changes, select the Refresh button at the top of the web view.
Note that web view is simply a browser and is not tied to other JBuilder
features. For example, you can view your formatted output in a browser
external to JBuilder. Options on the Web page of the IDE Options dialog
box speed up repeated use of this feature. See Configuring the IDE for
web run/debug on page 9-7.
10-15
10-16
The first time you press the Reset Program button, it simply sends a
command to the server to shutdown. In particular, if you are trying to
debug your webapps lifecycle event handlers, this would call the
Servlet.destroy() and ServletContextListener.contextDestroyed() methods.
If youre not debugging, the server will usually shutdown by itself
(Tomcat does this in a few seconds; other server take longer). In any case,
if you press the Reset Button a second time, the server process is
terminated immediately.
JBuilder provides source debugging for JSPs. This allows you to trace
through your JSP code directly; you dont need to trace through the
servlet that the JSP is compiled to and try to match up line numbers in
order to find errors. Note that Tomcat 4.1 does not support JSP source
debugging.
10-17
The Web Debug command displays the debugger in the web server pane.
Both web server and debugger messages are written to the Console view
of the debugger.
Note
10-18
Chapter
11
Deploying your web application
Chapter11
Web Development is a
feature of JBuilder
Enterprise
Overview
The following sections discuss some issues you will want to consider
when deploying to any web server.
Archive files
Gathering your web applications files into an archive can greatly simplify
deployment. Some servers require a WebApp to be packaged in a WAR
(Web Archive) file. A WAR file organizes the files you need for your web
application into the correct hierarchy. You can then copy the archive file to
the appropriate location on your web server. This eliminates the need to
copy each file individually and ensures they get copied to the proper
locations.
A WAR file is a web archive. It can contain your entire web application in
an appropriate structure, making that structure easier to replicate on the
web server. WAR files are discussed in more detail in Chapter 3,
Working with WebApps and WAR files.
11-1
Overview
If your web application contains one or more applets, you might consider
putting them in a JAR file. For more information on using JAR files to
contain applets, see Chapter 14, Working with applets.
Your web application, WAR file, or JAR file can also be packaged into an
EAR file. See the online help for the EAR wizard.
Deployment descriptors
Deployment descriptors are XML files which contain information needed
by the web server about the WebApp. You will use one or more
deployment descriptors if your web application contains servlets or JSPs.
Check your servers documentation for more information about what
deployment descriptor(s) it requires.
Applets
See Deploying applets on page 14-12 for information on deploying an
applet.
Servlets
Servlet deployment can be tricky, because if its not done correctly, the
web server will fail to recognize your servlet. In order to simplify
deployment, you should consider archiving your servlet into a WAR file.
This enables you to gather all the files and resources that are needed for
the servlet together in a correctly organized hierarchy prior to
deployment. Then you only need to deploy the WAR file to the web
server.
Regardless of the web server, successful servlet deployment requires
certain information to be present in the web.xml deployment descriptor.
Your web server could also have additional requirements. At minimum,
before deploying a standard servlet, you will need to specify the following
in a servlet element of the web.xml file:
servlet-name a name for the servlet
servlet-class the fully qualified class name for the servlet
Each standard servlet must also specify a servlet-mapping in the web.xml.
You will need to specify the following within a servlet-mapping element:
servlet-name the name used in the servlet tag
url-pattern the URL pattern to which the servlet is mapped
11-2
Overview
A filter servlet or a listener servlet will require different tags. See Filters
page on page 12-4 and Listeners page on page 12-6 for more
information on the required tags for these types of servlet.
If you use JBuilders Servlet wizard to build your servlet, the wizard will
insert the required information for the servlet into the web.xml for you. This
is true for a standard servlet, a filter servlet, or a listener servlet.
Servlets must be compiled before being deployed to the web server.
JSPs
JSPs are easier to deploy than servlets. You might want to consider
archiving them into a WAR file to make deployment even easier.
JSPs are mapped by a web server in the same way that HTML files are; the
server recognizes the file extension. Compilation is also handled by the
web server. Remember, JSPs are compiled into servlets by the web server
prior to execution.
Some JSPs use JSP tag libraries. These libraries also must be deployed to
the web server, and the web server needs to know how to find them. For
this reason, if you have a JSP that uses a tag library, your web.xml
deployment descriptor will require a taglib element which indicates
which tag library to use and where it can be found. The following
information is found in the taglib element:
taglib-uri the URI used in the JSP to identify the tag library. This
matches the taglib directive (<%@ taglib uri="whatever"
prefix="whatever">) in the JSP.
taglib-location the actual location of the tag library.
If you use JBuilders JSP wizard to create a JSP which uses one of the tag
libraries thats recognized by the wizard, the tag library information is
added to web.xml for you.
11-3
If you enter comments in the web.xml file using the source editor, these will
be removed if you subsequently open the file in the WebApp DD Editor.
JBuilder also provides the Struts Config Editor for editing the
struts-config.xml deployment descriptor required by the Struts
framework.
11-4
Vendors who offer plug-ins for web servers other than Tomcat are
encouraged to provide GUI editors for their vendor-specific deployment
descriptors. For example, the Sybase plug-in provides a GUI editor for the
sybase-easerver_config.html file.
If your vendor doesnt provide a GUI editor for their deployment
descriptor, you can still edit the deployment descriptors source code in
JBuilders XML source editor. To do this, you open the vendor-specific
deployment descriptor and click the Source tab in the content pane.
When a vendor-specific deployment descriptor is opened in the JBuilder
IDE, its contents are displayed in the structure pane, and the AppBrowser
displays the source editor and the history view, along with any
vendor-specific GUI editor which may be provided by your web server
plug-in.
11-5
11-6
Chapter
12
Editing the web.xml file
Chapter12
The WebApp DD Editor is active when the web.xml file is opened in the
content pane. At the same time, the structure pane shows an outline of the
contents of the file. Clicking the various nodes within the structure pane
displays various pages of the editor. There are 15 main nodes, and some of
these have child nodes. Here is a list of the main nodes:
WebApp Deployment Descriptor
Context Parameters
Filters (Servlet 2.3 specification)
Listeners (Servlet 2.3 specification)
Servlets
Tag Libraries
MIME Types
Error Pages
Environment Entries
EJB References
Local EJB References (Servlet 2.3 specification)
Resource Manager Connection Factory References
Resource Environment References (Servlet 2.3 specification)
Login
Security
12-1
Each of these nodes contain tags you can edit in the WebApp DD Editor.
The WebApp DD Editor covers all the web.xml deployment descriptor tags
in the Servlet 2.3 specification. You can also edit the source of the web.xml
file.
Caution
If you enter comments in the web.xml file using the source editor, these will
be removed if you subsequently open the file in the WebApp DD Editor.
The tags contained in each of the WebApp DD Editors nodes are
discussed in the following sections.
12-2
Item
Description
Large icon
Small icon
Table 12.1
Item
Description
Display name
Description
Session timeout
Distributable
Welcome files
12-3
Filters page
Filters page
The Filters page will only be visible if your web server supports the
Servlet 2.3 specification. This page contains a grid to map the filters (by
filter-name) to either a URL pattern or a servlet name (but not both). The
order of the filters is important because it is the order in which the filters
will be applied. This page allows you to change the order in which the
filters are applied. The following describes the information presented on
the filters page:
Table 12.2
Item
Description
URL Pattern
The url-pattern for the location of the filter. Either this or the
servlet-name is required when deploying a filter servlet.
Servlet Name
Filter Name
If you use JBuilders Servlet wizard to create a filter servlet, the wizard
will add the required filter mapping for you.
12-4
Filters page
Item
Description
Large icon
Points to the location of a large icon for the filter (32 x 32 pixels),
which must be contained within the WebApps directory tree.
Small icon
Points to the location of a small icon for the filter (16 x 16 pixels),
which must be contained within the WebApps directory tree.
Filter class
Display name
Description
Init parameters
12-5
Listeners page
Listeners page
The Listeners page will only be visible if your web server supports the
Servlet 2.3 specification. The Listeners page has a list box of web
application listener classes. The order of the listeners is important because
it is the order in which the listeners will be applied. The Listeners page
allows you to change the order in which the listeners are applied. The
information on the Listeners page is required when deploying a listener
servlet. If you use JBuilders Servlet wizard to create a listener servlet, the
servlet class will be added to the list for you.
12-6
Servlets page
Servlets page
The Servlets page has a grid mapping URL patterns to a servlet-name. Note
that a servlet can be mapped to more than one URL pattern. At least one
servlet mapping is recommended for each servlet. If you use JBuilders
Servlet wizard to create a standard servlet, it will fill in the servlet
mapping for you.
12-7
Servlets page
If any servlets are defined, you will find child nodes representing
individual servlets underneath the Servlets page node in the structure
pane. The servlets servlet-name is displayed in the tree. You can rename or
delete a servlet by right-clicking the node for the individual servlet and
selecting Rename or Delete from the context menu. If you do rename or
delete a servlet, this change will be cascaded to all relevant parts of the
deployment descriptor. For example, removing a servlet also removes all
its URL and filter mappings.
Keep in mind that you can also map URL patterns to JSPs. This means that
an individual servlet node in the structure pane may represent a JSP or a
servlet.
When an individual servlet node is opened, the WebApp DD Editor
displays a page for that specific servlet. This page contains identifying
information for the servlet:
Table 12.4
12-8
Item
Description
Large icon
Small icon
Servlets page
Table 12.4
Item
Description
Servlet class
Select this radio button for a servlet. Enter the fully qualified
class name for the servlet in the text field.
JSP file
Select this radio button for a JSP. Enter the path to the JSP file
in the text field.
Display name
Description
Load Priority
Run As
Init Parameters
12-9
12-10
txt text/plain
html text/html
xml text/xml
pdf application/pdf
zip application/x-zip-compressed
jpeg image/jpeg
gif image/gif
12-11
12-12
12-13
12-14
Login page
Login page
The Login page displays a set of radio buttons for choosing the
authentication method for the WebApp. The default is none. Other options
are Digest, Client-Cert, Basic and Form. For Basic, you can specify a Realm
name. For Form, you can specify a Login page and a login Error page.
Figure 12.15 Login page in WebApp DD Editor
12-15
Security page
Security page
The Security page has a grid of role names and their descriptions.
Figure 12.16 Security page in WebApp DD Editor
Security constraints
Each security constraint is listed as a separate child node of the Security
node. You can delete a security constraint by right-clicking the node for
the individual constraint and selecting Delete from the context menu. If
you do delete a constraint, this change will be cascaded to all relevant
parts of the deployment descriptor.
When an individual security constraint node is opened, the WebApp DD
Editor displays the information for that security constraint: the transport
guarantee, the role names that are authorized, and descriptions for both.
In addition to specifying authorization role names separately, the reserved
role-name * indicates all roles. If this designation is used in addition to
individual role names, the individual names are ignored. The security
constraint page in the WebApp DD Editor includes an All Roles
Authorized checkbox that is visible only when editing a Servlet 2.3 web.xml
file.
12-16
Security page
12-17
Security page
Item
Description
Description
HTTP methods
A set of check boxes for the HTTP methods (such as GET and
POST) that apply to the URL patterns. Selecting none of the
check boxes is the same as selecting all of them.
URL patterns
A list box of the URL patterns for this web resource collection.
12-18
Chapter
13
Editing the struts-config.xml file
Chapter13
Web Development is a
feature of JBuilder
Enterprise
13-1
Note
If you use JBuilders wizards to create the pieces of your Struts web
application, you may not need to edit the struts-config.xml file.
As you use JBuilder to create the pieces of your web application, the
web.xml deployment descriptor file is automatically updated for Struts. For
more information, see Struts framework implementations in JBuilder on
page 8-14 .
Important
JBuilder 8 supports Struts 1.0 and does not officially support the beta
release of Struts 1.1. However, if you enable your struts-config.xml file for
Struts 1.1 and download the Struts 1.1 JAR file to the <jbuilder>/extras
folder, you will see support for Struts 1.1. The Struts Config Editor will
display elements and attributes specific to 1.1.
13-2
To display the Data Sources overview page of the Struts Config Editor,
choose the Data Sources node in the structure pane. The Data Sources
overview page displays existing <data_source> elements. You use this page
to add and remove elements.
To add a new <data-source> element, click the Add button. A new
element is added with a default name of dataSource.
To remove an element, select it and choose Remove.
To edit the newly added element or an existing one, select it and choose
Edit.
Figure 13.1 Data Sources overview page
13-3
You use the Data Sources attribute page to edit the attributes of a
<data-source> element. The attribute page looks like this:
Figure 13.2 Data Sources attribute page
13-4
Field Name
Attribute Name
Description
Key
key
Implementation
Class
type
Property
Value
Node
Menu command
Description
Add DataSource
Add DataSource
Delete
13-5
To display the Form Bean overview page of the Struts Config Editor,
choose the Form Beans node in the structure pane. The Form Beans
overview page displays existing <form-bean> elements. You use this page to
add and remove elements.
To add a new <form-bean> element, click the Add button. A new element
is added with a default name of formBean.
To remove an element, select it and choose Remove.
To edit the newly added element or an existing one, select it and choose
Edit.
Figure 13.3 Form Beans overview page
You use the Form Bean attribute page to configure the attributes of a
<form-bean> element. The attribute page looks like this:
Figure 13.4 Form Bean attribute page
13-6
Attribute Name
Description
Name
name
Implementation Class
type
Configuration Bean
className
Property
(Set Properties tab)
property-name, for
example id. A property
is not required.
Value
(Set Properties tab)
Large Icon
(Description tab)
large-icon
Small Icon
(Description tab)
small-icon
Display Name
(Description tab)
display-name
Description
(Description tab)
description
Contains descriptive
(paragraph length) text about
the surrounding element,
suitable for use in GUI tools.
13-7
Node
Menu command
Description
ActionForm Wizard
Delete
13-8
To display the Global Forwards overview page of the Struts Config Editor,
choose the Global Forwards node in the structure pane. The Global
Forwards overview page displays existing <forward> elements. You use
this page to add and remove elements.
To add a new <forward> element, click the Add button. A new element is
added with a default name of forward.
To remove an element, select it and choose Remove.
To edit the newly added element or an existing one, select it and choose
Edit.
Figure 13.5 Global Forwards overview page
13-9
13-10
Forward attributes
Field Name
Attribute Name
Description
Name
name
Path
path
Redirect
redirect
Configuration Bean
className
Property
(Set Properties tab)
property-name, for
example id. A property
is not required.
Value
(Set Properties tab)
Large Icon
(Description tab)
large-icon
Small Icon
(Description tab)
small-icon
Display Name
(Description tab)
display-name
Description
(Description tab)
description
Node
Menu command
Description
Global Forwards
node
Add Forward
Global Forwards
element
Add Forward
Global Forwards
element
Delete
13-11
13-12
Action attributes
Field Name
Attribute
Name
Description
Implementation
Class
type
Forward
forward
Include
include
Path
path
Configuration
Bean
className
Parameter
parameter
Handle Unknown
Requests
unknown
Form Bean
(Form Bean tab)
name
Prefix
(Form Bean tab)
prefix
Scope
(Form Bean tab)
scope
13-13
Table 13.7
Field Name
13-14
Attribute
Name
Description
Input
(Form Bean tab)
input
Attribute
(Form Bean tab)
attribute
Suffix
(Form Bean tab)
suffix
Validate
(Form Bean tab)
validate
Property (Set
Properties tab)
property
Value (Set
Properties tab)
value
Path (Forwards
tab)
path
Name (Forwards
tab)
name
Large Icon
(Description tab)
large-icon
Small Icon
(Description tab)
small-icon
Table 13.7
Field Name
Description
Display Name
(Description tab)
display-name
Description
(Description tab)
description
Node
Menu command
Description
Action Mappings
node
Add Action
Action Mappings
node
Action Wizard
Action Mappings
element
Add Action
Action Mappings
element
Add Forward
Action Mappings
element
Delete
13-15
13-16
Chapter
14
Working with applets
Chapter14
Applet development is a
feature of all editions of
JBuilder
If you have already tried to write applets and deploy them to a web site,
youve probably discovered that, compared to applications, applets
require dealing with additional issues to make them work. Deploying and
testing applets outside the IDE is where difficulty usually begins, and if
you have not handled some basic applet issues correctly, your applet will
not work properly. To succeed, you need to know how applets work and
how all the pieces fit together, especially when it comes to deploying and
uploading them to an external web site.
See also
Tutorial: Building an applet in Introducing JBuilder
The Java tutorial on Writing Applets at
http://java.sun.com/docs/books/tutorial/applet/index.html
Suns web site at http://java.sun.com/applets/index.html
The Java FAQ at http://www.afu.com/javafaq.html
Charlie Calverts Java Madness, Part II: Applets at
http://homepages.borland.com/ccalvert/JavaCourse/index.htm
Rich Wilkmans Java Curmudgeon web site at
http://formlessvoid.com/jc/applets/
John Moores Applet design and deployment at
http://www.microps.com/mps/p_appletdesign.html
14-1
Item
Description
codebase
archive
code
(required)
The fully qualified name of the applet class that contains the
init() method. For example, if the class Applet1.class is part of a
package called test, then code would be
code="test.Applet1.class".
name
(optional)
width/height
(required)
hspace/vspace
(optional)
param
(optional)
14-3
Browser issues
Browser issues
One of the primary tasks in getting applets to work at runtime is solving the
various issues with the browsers that host the applets. Browsers vary in the
level of JDK support and each browser approaches Java implementation
differently. The most frequent issues youll encounter concerning browsers
include Java support, getting the preferred browser to the end user,
multiple browser support, and differences in Java implementation.
Java support
A common problem with applets is a JDK version mismatch between your
applet and the browser running it. There are many users who have not
upgraded or updated their browsers. These browsers may not support the
newer JDKs from Sun. Swing, introduced in JDK 1.1.7, may not be
supported by some browsers. The most common error will be
NoClassDefFoundError on some class in the java.* packages because the
ClassLoader determined it needed a Java class or method that the browser
JDK does not support.
JDK 1.2, 1.3, and 1.4 are still not fully supported in all browsers. While it is
true that recent versions of the browsers support Java, you should know
what specific version of Java is supported in the browsers that will run
your applet. This is important so you can do whatever is necessary to
create a match between the version of the JDK used in your applet and the
JDK supported by the browsers.
To find out what JDK version the browser supports, check the Java
Console in the browser or check the browsers web site.
To open the Java Console, do one of the following:
Select Communicator|Tools|Java Console in older versions of
Netscape or Tasks|Tools|Java Console in more recent versions.
Select View|Java Console in Internet Explorer.
The Java Plug-in from Sun easily solves the problem of JDK mismatch
by permanently downloading the same version of the JDK to all the
end-users machines.
14-5
Browser issues
14-6
Browser issues
There are several plug-in versions: JDK 1.1.x, 1.2x, 1.3x and 1.4. You
must use the version that matches the JDK used by your applet. In
addition, the HTML Converter version must match the plug-in version.
Also note that you can have only one version of the plug-in on the
client machine.
Use the same version of the JDK supported by the browsers
You can avoid many problems by writing applets using the same JDK
that the browsers support. JBuilder SE and Enterprise allow you to
switch the JDK version you are using for development. Although
JBuilder Personal does not support JDK switching, you can edit the
current JDK. See Tools|Configure JDKs and Editing the JDK in the
Creating and managing projects chapter of Building Applications with
JBuilder.
14-7
created automatically by the wizard. Once you have your applet built
and running in this situation, you can archive everything into one JAR
or ZIP file. Then, test your applet outside JBuilder in the browsers.
Tip
You can use a copy of the actual HTML page that is on your site in the
local project, instead of a simpler test one. That makes the external
testing a little more realistic. When youre satisfied, upload the entire
directory to your web site.
Use packages
You should always use packages to organize similar classes when
coding in Java. This makes them easier to find and makes deployment
much simpler. Packages also help avoid conflicts with class names,
because the package name is added before the class name in Java.
Use the latest browser
Know the browsers on which your applet will run. If you are using
current tools like JBuilder, you are likely to be generating JDK 1.3.x or
later code and will need the latest browser(s) to run your applets. Make
sure you provide the latest patch or plug-in to match the browsers JDK
version with the applets. See Java Plug-in found at
http://java.sun.com/products/plugin/.
Match case
Remember that Java is case-sensitive. Check that all case in class,
package, archive, and directory names in the <applet> tag exactly match
the names on the server.
Use archive files
Archives simplify deployment, because you only have to upload the
HTML file and your archive file(s). They also speed up the
downloading process to the client; one compressed file is downloaded
rather than each individual, uncompressed class file. Always check the
directory structure and the case of file names in the archive file for
accuracy. See Deploying applets on page 14-12 and Deploying
applets in JBuilder on page 14-23 for more information on creating
archive files.
Important
14-9
The sandbox
Applets address this concern by running all untrusted code in a safe
environment called the sandbox. While an applet is in the sandbox, it is
under the watchful eye of a security manager. The security manager
protects the client machine from harmful programs that might delete files,
read secure information, or do anything that is a violation of the security
model being used. The restrictions placed by the security manager, in
turn, limit what an applet can do.
Understanding these limitations before writing your applets can save time
and money. Applets, like any tool, accomplish certain tasks very well. But,
trying to use an applet in the wrong context only leads to problems.
Applet restrictions
By default, all applets are untrusted and are blocked from specific
activities, such as
Reading and writing from the local disk
You cant read files, check for their existence, write files, rename files,
and so on.
14-10
Connecting to another machine other than the one from which the
applet came
This makes it difficult to provide data from a database that lives on a
different machine than the web server.
There are other activities taken for granted by application developers,
such as running local system programs to save time, which are not
allowed in applets. Any good Java book will list the restrictions placed on
applets.
If you find that you are trying to bypass the security manager at any point
in your planning or development, consider using an application instead.
Sun has done a very good job of defining their security model and
identifying the key bits of information, or data types, on which entire sets
of functionality depend. As a result, it is very difficult to trick the security
model.
14-11
The larger the applet, the longer it takes to download and run.
Deploying applets
Deployment is the process of gathering the applets classes and their
dependents in the correct hierarchy for deployment to a server. JBuilder
SE and Enterprise provide the Archive Builder for deployment within
JBuilders IDE after applet development. Sun provides the jar tool in the
JDK.
14-12
Testing applets
If you are writing JDK 1.1.x applets with Swing components, which is not
recommended due to browser issues, you also need to download and
deliver the JFC (Swing) classes, swingall.jar, as they were not delivered as
part of the JDK.
See also
Deploying applets in JBuilder on page 14-23
Deploying Java programs in Building Applications with JBuilder
jar tool in the JDK documentation
Java Web Start and JBuilder on page 15-4
Testing applets
The main purpose of an IDE is to enable you to develop and test your code
locally. When you run an application or an applet in JBuilder, if the
program needs a particular class, JBuilder goes to great lengths to find
that class. This actually allows you to focus on developing your
application or applet and making sure it works.
However, it does not give you accurate runtime behavior for applets. To
properly test an applet, you need to test it with the applet deployed to the
web server in its actual running environment. This is the only way to
make sure all the classes the applet needs are available on the server
running it.
When you run your applet in a browser, the applet needs to have enough
information inside the <applet> tag of the HTML file to allow the applet
loader to find all the classes, images, and other assorted files your applet
needs. This environment is the entire real world of your applet and is
the only place the applet gets the information it needs for finding the files.
For the first tests of your deployed applet, consider using the JDK
appletviewer test browser. This command-line tool included in the JDK
provides useful displays of error messages and stack traces. As
demonstrated in the following steps, remove the CLASSPATH in the testing
session.
14-13
Testing applets
<jbuilder> is the name of the JBuilder directory and <jdk> is the name of
the JDK directory. For example, JBuilder8/jdk1.4/.
Note
14-14
14-15
If youre creating an applet for the Web, see Browser issues on page 14-5
for information on browser and JDK compatibility issues before designing
your applet.
1 Choose File|New Project to create a new project for your applet. The
Project wizard appears, suggesting a default project name and
directory. Change the project file name and the project directory if you
want to give the project a particular name and location. Click the
Generate Project Notes File option to create a descriptive HTML file for
your project.
Note
The paths for the project files are pre-set in the default project
properties. Unless you are an advanced Java user, its best to leave
these unchanged. For more information on the default project
properties, see Creating and managing projects in Building
Applications with JBuilder.
The name of the package for the project is derived from the project file
name and is displayed in the Applet wizard. For example, if you create
a project called <home>/jbproject/AppletProject, the Applet wizard
suggests using a package name of appletproject.
For more information on packages, see Packages in the Creating and
managing projects chapter of Building Applications with JBuilder.
Backup path
Working directory
Source path
Documentation path
The Output, Backup and Working Directory paths and the JDK path
can be edited by selecting the ellipsis button. The Source, Test and
Documentation paths can be editing by selecting the path and then
selecting the Edit button. Required libraries can also be added.
14-16
See also
Setting the JDK in Building Applications with JBuilder
How JBuilder constructs paths in Building Applications with
JBuilder
2 Next, choose File|New and choose the Web tab of the object gallery.
3 Double-click the Applet icon in the object gallery to open the Applet
wizard.
a Do not change the suggested package name. Type a new name for
the applet class if you like.
b Select the base class you want the applet to extend:
java.applet.Applet (AWT class) or java.swing.JApplet (JFC Swing
class).
c Check any of the remaining options you want:
Generate Header
Comments
Can Run
Standalone
Generate Standard
Methods
d Click Next to go to the Applet Parameters page. In this step, you can
add parameters. From this information, the wizard generates <param>
tags within the <applet> tag of the applet HTML file and
parameter-handling code in the new applet java file.
Fill in one row for each parameter you wish to have.
To add a new parameter, click the Add Parameter button.
To select a cell, click it or use the keyboard navigation arrows to
move to it.
To enter a value in a cell, type in a value, or select one if a
drop-down list exists.
14-17
Type
Desc
Variable
Default
14-18
See also
Creating applets with the Applet wizard on page 14-16
Tutorial: Building an applet in Introducing JBuilder
Running applets
To run an applet within a project,
You can also select the applet .java file if it has a main() method and choose
Run. You can create an applet with a main() method by selecting the Can
Run Standalone option on the Enter Applet Class Details page of the
Applet wizard.
The applet compiles and runs if there are no errors. The build progress is
displayed in a dialog box and the message pane displays any compiler
errors. If the program compiles successfully, the classpath is displayed in
the message pane and the applet runs.
14-19
Main class
When you select a main class to run the applet, it runs in JBuilders applet
viewer, AppletTestbed. When you create your applet using the Applet
wizard, it sets the main class for you automatically. The selected class
must contain an init() method.
HTML file
When you select an HTML file to run the applet, it runs in Suns
appletviewer. The HTML file must contain the <applet> tag and the code
attribute must contain the fully qualified class name. If the class file is not
located in the same directory as the HTML file, the codebase attribute must
specify the location of the class file in relation to the HTML file.
14-20
Debugging applets
You can debug applets in JBuilders IDE just as you would debug any Java
program. Just as there are two ways to run applets in JBuilder, you can
also debug applets two ways: JBuilders AppletTestbed and Suns
appletviewer.
To debug with JBuilders AppletTestbed, you must run the main applet
class which contains the init() method:
1 Set the applets main class, which contains the init() method, as the
runnable class (use a runtime configuration.)
2 Compile the project.
3 Set a breakpoint in the applet file.
4 Choose Run|Debug Project or click the Debug button on the toolbar.
The debugger takes control.
Note
If youre developing your applet using an older JDK, youll need to switch
to a newer JDK (JDK 1.2.2 and above) to debug. Earlier JDKs do not
support JPDA debugging API (Java Platform Debugger Architecture) that
JBuilder uses. See Setting the JDK in Building Applications with JBuilder.
For detailed instructions on debugging in JBuilder, see Debugging Java
programs in Building Applications with JBuilder.
To debug with Suns appletviewer, you must run the HTML file using
one of these methods:
From the project pane, follow these steps:
14-21
a Set the applets HTML file as the runnable file by modifying the
runtime configuration.
b Compile the project.
c Set a breakpoint in the applet file.
d Choose Run|Debug Project or click the Debug button on the toolbar.
The debugger loads in the message pane and the applet runs in Suns
appletviewer.
You can also debug applets from within Internet Explorer 5 or Netscape
Navigator 6 and above using the Java Plug-in and JBuilders debugger.
To debug using JDK 1.4,
1 Download and install the plug-in for JDK 1.4 from the Sun site:
http://java.sun.com/products/plugin/.
2 Set the following runtime parameters in the Java Runtime Parameters
field on the Advanced tab of the Java Plug-in Control Panel:
-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,address=3999,suspend=n
14-22
6 Start Netscape or Internet Explorer and open the HTML file. Be sure the
browser has Java enabled. Refer to the browsers online help for more
information.
7 Switch to JBuilder and set a breakpoint in the applet file. Start
debugging your project. The debugger should start up successfully.
Switch back to the browser and refresh the page. In JBuilder, the
debugger should stop at the breakpoint in the applet.
See also
Using the Archive Builder in Building Applications with JBuilder
Deploying Java programs in Building Applications with JBuilder
jar tool at http://java.sun.com/j2se/1.3/docs/tooldocs/tools.html#basic
Chapter 3, Working with WebApps and WAR files
14-23
14-24
Chapter
15
Launching your web application
with Java Web Start
Chapter15
Web Development is a
feature of JBuilder
Enterprise
15-1
Name
Methods for
BasicService
ClipboardService
DownloadService
FileOpenService
FileSavService
PrintService
PersistenceService
FileContents
For more information, see JNLP API Examples in the Java Web Start
Developers Guide at http://java.sun.com/products/javawebstart/docs/
developersguide.html#api.
15-2
15-3
You dont need the Web Start library in every Web Start-enabled
application or applet. You only need to add the library to your project
when youre using the JNLP API. In this case, you should also get the
developers download, containing additional jars and documentation,
from the Web Start web site at http://java.sun.com/products/javawebstart/.
Important
Some extra setup is required if you are using Netscape 6. For more
information, go to the topic called Using Java Web Start Technology with
Netscape 6 Web Browsers in the Java Web Start Installation Guide at
http://java.sun.com/products/javawebstart/docs/installguide.html.
1 Set up a web server, for example, Tomcat 4.0, for your project. For more
information on web servers, see Chapter 9, Configuring your web
server.
15-4
Archive Builder
Option
Step 1
Step 2
For more information on creating JAR files, see Using the Archive
Builder in Building Applications with JBuilder.
Option
Step 1 Enter
required information
Step 3 Enter
descriptive information
15-5
Using Java Web Start with applets solves the browser mismatch problem.
As long as the browser has the Java Web Start plugin, it can automatically
download the appropriate JDK to run the applet. The main class for a Java
Web Start applet is the actual applet class to run. The Applet information
page gathers a few values that are necessary to simulate the applet
running in a web page, where an applet would expect to be running
(when in fact it is being hosted by the Java Web Start plugin).
The Web Start Launcher wizard assumes youve already created and built
your applications JAR file.
Warning
The Web Start Launcher wizard gives the same name to the JNLP and
HTML files. If the name entered in the Name field on Step 1 of the wizard
matches the name of an existing HTML or JNLP file in your project, you
are asked if you want to overwrite the existing file.
The JNLP file is an XML document. The elements in the file describe
application features, such as the application name, vendor, and
15-6
homepage; as well as JNLP features. For more information, see JNLP File
Syntax in the Java Web Start Developers Guide at
http://java.sun.com/products/javawebstart/docs/developersguide.html.
Note
Before you deploy your web start application, you must change the
codebase attribute in the JNLP file. This attribute is automatically
generated as localhost:8080. Youll need to change it to match your web
server. Java Web Start 1.2 now includes a servlet to automatically generate
the appropriate codebase as part of the Developers kit. See
http://java.sun.com/products/javawebstart/1.2/docs/
downloadservletguide.html for more information.
Your applications homepage is an HTML file that contains both JavaScript
and VBScript code and HTML tagging. The script determines if you are
running the HTML file within JBuilder or from an external web browser. If
youre in JBuilder, youll see a message in the web view explaining that you
need Java Web Start to run this application. The web view looks like this:
Figure 15.1 Web view for Java Web Start
If youre in the external browser, youll see a link to your application (if
you have already installed Web Start). Click the link to launch Java Web
Start and run your application. The external browser looks like this:
Figure 15.2 External browser for Java Web Start
Important
15-7
15-8
Chapter
16
Tutorial: Creating a
simple servlet
Chapter16
Web Development is a
feature of JBuilder
Enterprise
This tutorial shows how to develop and test a servlet within JBuilder,
using the Tomcat servlet engine. The servlet accepts user input and counts
the number of visitors to a web site. The servlet, generated with the
Servlet wizard, displays a form for submitting a user name. When the
form is submitted, the servlet is modified to display the user name and a
counter for the number of visitors.
All servlets are built by extending the basic Servlet class and defining Java
methods to deal with incoming connections. This sample servlet extends the
HttpServlet class that understands the webs HTTP protocol and handles
most of the underlying plumbing required for a web application.
For more information on servlets, read the following chapters:
Chapter 4, Working with servlets
Chapter 5, Creating servlets in JBuilder
For more information on web applications, read Chapter 3, Working
with WebApps and WAR files.
This tutorial assumes you are familiar with Java and with the JBuilder
IDE. For more information on Java, see Getting Started with Java. For more
information on the JBuilder IDE, see The JBuilder environment in
Introducing JBuilder.
See the Tutorials section in the JBuilder Quick Tips for useful information
about viewing and printing tutorials. The Accessibility options section in
the JBuilder Quick Tips contains tips on using JBuilder features to
improve JBuilders ease of use for people with disabilities.
For information on documentation conventions used in this tutorial and other
JBuilder documentation, see Documentation conventions on page 1-4.
Tutorial: Creating a simple servlet
16-1
1 Choose File|New to display the object gallery. Click the Web tab and
choose Web Application. Click OK.
The Web Application wizard is displayed.
16-2
16-3
16-4
16-5
The following table describes the fields and values to use for this
tutorial. Enter the values that are in the Value column of the following
table.
Table 16.1
Parameter
Name
Value
Description
Name*
UserName
Type*
String
Desc
Name of User
Variable*
userName
Default
User!
When youre finished, the Enter Servlet Request Parameters page of the
wizard will look like this:
near the top of the file. Immediately before that line, type the following
line of code:
int connections = 0;
You can also run servlets directly by right-clicking the .java file in the
project pane, and selecting Web Run. In this example, you are running the
servlet from the SHTML file because that is where the parameter input
fields and Submit button are coded, based on our selections in the Servlet
wizard.
Running the SHTML file starts Tomcat, JBuilders default web server. The
output from Tomcat is displayed in the message pane. HTTP commands
16-7
and parameter values are also echoed to the output pane. Two new tabs
appear in the content pane for the servlet: Web View and Web View
Source. The running servlet displays in the web view. It looks like this:
Figure 16.1 Servlet running in the web view
To run the servlet, type a name, such as User in the text box, then click the
Submit button. The doPost() method is called, and the response is
displayed in the web view, as shown below.
Figure 16.2 Servlet running after name submitted
To run the servlet again and see the number of connections increase, click
the back arrow at the top of the web view. Type another user name and
click the Submit button. When the reply from the doPost() method is
displayed, youll see that the number of connections has increased.
16-8
To stop the web server, click the Reset Program button directly above the
web server tab. If you make changes to your source code, you should stop
the web server before re-compiling and re-running.
You have completed your first servlet program. For a more advanced
servlet that connects to a database, see Chapter 17, Tutorial: Creating a
servlet that updates a guestbook.
16-9
16-10
Chapter
17
Tutorial: Creating a servlet that
updates a guestbook
Chapter17
Web Development is a
feature of JBuilder
Enterprise
This tutorial shows how to create a servlet that accepts user input and
saves the data to a JDataStore database.
When you complete this tutorial, your project will contain the following
classes:
FormServlet.java This is the runnable class in the program. Its doGet()
method displays an input form using an HTML <form> tag. The servlet
posts the user values (via parameters) to DBServlet.
DBServlet.java This servlet passes parameter values (in its doPost()
method) to DataModule1. Code in the doGet() method renders the
Guestbook JDataStore as an HTML table.
DataModule1.java The data module that contains the programs
business logic. Code in the data module connects to the Guestbook
JDataStore, updates it, and saves changes.
This tutorial assumes that you are familiar with servlets and with
JBuilders JDataStore and DataExpress technologies. For more information
on servlets, see
Chapter 4, Working with servlets
Chapter 5, Creating servlets in JBuilder
17-1
To get started, you can also work through a less complex Hello World
servlet see Chapter 16, Tutorial: Creating a simple servlet. For more
information about JBuilders database functionality, see the Database
Application Developers Guide. For more information about JDataStore, see
the JDataStore Developers Guide.
The completed sources for this tutorial can be found in the samples/
WebApps/GuestbookServlet directory of your JBuilder installation.
See the Tutorials section in the JBuilder Quick Tips for useful information
about viewing and printing tutorials. The Accessibility options section in
the JBuilder Quick Tips contains tips on using JBuilder features to
improve JBuilders ease of use for people with disabilities.
For information on documentation conventions used in this tutorial and
other JBuilder documentation, see Documentation conventions on
page 1-4.
17-2
4 Make sure that Tomcat 4.0 is selected in the server drop-down list. The
Server tab should look similar to this:
1 Choose File|New to display the object gallery. Click the Web tab and
choose Web Application. Click OK.
The Web Application wizard is displayed.
17-3
17-4
To create FormServlet.java,
1 Choose File|New to display the object gallery. Click the Web tab and
choose Servlet. Click OK.
The Choose Servlet Name and Type page of the Servlet wizard is
displayed.
17-5
5 Make sure that the Content Type option is set to HTML and that the
doGet() method is selected. Uncheck the Generate SHTML File option.
When youre finished, the Enter Standard Servlet Details page of the
wizard should look like this:
17-6
8 Click Finish to create the servlet. You do not need to set other options.
9 Choose File|Save All or click on the toolbar to save your work.
To create DBServlet.java,
1 Choose File|New to display the object gallery. Click the Web tab and
choose Servlet. Click OK.
The Choose Servlet Name and Type page of the Servlet wizard is
displayed.
2 Leave the package name set to guestbookservlet. Change the Class field
to DBServlet.
3 Make sure the Generate Header Comments and Single Thread Model
options are not selected. The WebApp guestbook should be selected in
the WebApp drop-down list. Leave the Standard Servlet option
selected.
The Choose Servlet Name and Type page of the wizard should look like
this:
17-7
When youre finished, the Enter Standard Servlet Details page should
look like this:
8 Click Finish to create the servlet. You do not need to set other options.
9 Choose File|Save All or click on the toolbar to save your work.
17-8
2 Leave the package name set to guestbookservlet. Keep the default Class
Name of DataModule1.
3 Uncheck the Invoke Data Modeler and Generate Headers options.
When youre finished, the Data Module wizard will look like this:
17-9
3 On the General page of the Connection dialog box, make sure the
Driver is set to com.borland.datastore.jdbc.DataStoreDriver.
4 Click the ellipsis button to the right of the URL field to display the
Create URL For DataStore dialog box. You use this dialog box to choose
the JDataStore to connect to.
5 Select the Local DataStore Database option.
6 Click the ellipsis button to browse to the Guestbook JDataStore
(guestbook.jds) in the samples/WebApps/guestbook directory of your
JBuilder installation. Click Open to select the JDataStore.
7 Click OK to close the Create URL For Datastore dialog box.
17-10
8 On the General page of the Connection dialog box, type user in the
Username field.
The Connection dialog box should look similar to this:
3 On the Query page, choose database1 from the Database drop-down list.
4 In the SQL Statement box, type:
SELECT SIGNATURES."Name",SIGNATURES."Comment" FROM SIGNATURES
This query loads all the values in the Name and Comment fields in the
SIGNATURES table of the Guestbook JDataStore. When you enter the
query, use the capitalization displayed above.
17-11
6 In the Load Options drop-down list, make sure the Load All Rows
option is selected.
The Query page of the Query dialog box should look like this:
7 Click the Test Query button to test the query. If the query is successful,
the word Success displays to the right of the button. If the query cannot
be executed, an error message attempts to explain why the query failed.
8 Click OK to close the Query dialog box.
JBuilder adds the queryDataSet1.setQuery() method to the jbInit()
method.
Note
You may see the following message displayed in the Designer tab of the
message pane:
Failed to create live instance for variable 'myDM'
guestbookservlet.DataModule1
For now, you can ignore this message. Youll fix this in a later step.
Click the X on the Designer tab at the bottom of the AppBrowser to
close it.
17-12
6 Click the Save All icon on the toolbar to save your work.
Now that the servlet is connected to the data module, you need to make
both servlets and the data module do something. From this point on in our
tutorial, youll be entering code directly into the editor. The first step will
be to create an input form in FormServlet.
17-13
You can search by positioning the cursor in the structure pane and
typing doGet.
You can copy and paste this code directly in the editor, or copy it from
the sample in the samples/WebApps/GuestbookServlet folder of your
JBuilder installation.
5 Click the Save All icon on the toolbar to save your work.
17-14
4 Insert the following lines of code, keeping the cursor at the location
where you just removed code:
String userName = request.getParameter("UserName");
String userComment = request.getParameter("UserComment");
dm.insertNewRow(userName, userComment);
dm.saveNewRow();
doGet(request, response);
Tip
You can copy and paste this code directly in the editor, or copy it from
the sample in the samples/WebApps/GuestbookServlet folder of your
JBuilder installation.
The first two lines of code get the values in the UserName and UserComment
parameters that are passed in from FormServlet. The next lines call two
methods in the data module:
insertNewRow() inserts the new Name and Comment values into
the last row of the table.
saveNewRow() saves the changes in the Guestbook JDataStore.
The last line calls the servlets doGet() method which renders the
Guestbook table in HTML.
Note
These methods have not been added to the data module yet, so you will
see errors in the Errors folder of the structure pane. You can ignore
these errors for now.
5 Click the Save All icon on the toolbar to save your work.
17-15
You can copy and paste this code directly in the editor, or copy it from
the sample in the samples/WebApps/GuestbookServlet folder of your
JBuilder installation.
2 Add the following packages to the list of import statements at the top of
the file. This ensures that the servlet will compile.
import com.borland.dx.dataset.*;
import com.borland.dx.sql.dataset.*;
import com.borland.datastore.*;
Tip
Note
17-16
The next two lines of code set up the output as HTML and start the HTML
page.
out.println("<html>");
out.println("<body>");
The following line of code prints the name of the JDataStore table,
SIGNATURES, at the top of the HTML page. The code uses the
queryDataSet1.getTableName() method to get the table name.
out.println("<h2>" + dm.getQueryDataSet1().getTableName() + "</h2>");
The next line calls the queryDataSet1.getColumns() method to get the column
names, and return them as an array.
Column[] columns = dm.getQueryDataSet1().getColumns();
The following line creates the table with the <table> tag and creates the
first row of the table.
out.println ("<table border = 1><tr>");
Then, the code uses a for loop to cycle through the column names in the
array of columns, retrieve the column captions, and display each caption
in a table row. In this tutorial, the program is only displaying the second
and third columns of the JDataStore. It is not displaying the first column,
the internal row number.
for (int i = 1; i < columns.length; i++) {
out.print ("<th>" + columns[i].getCaption() + "</th>");
}
The line following the for block closes the table row.
out.println("</tr>");
The next line positions the cursor on the first row of the JDataStore.
dm.getQueryDataSet1().first();
The while loop cycles through the JDataStore and displays data in the
second and third columns of the table. The first time through, it displays
the data in the first row. Then, the next() method positions the cursor on
the next row of the JDataStore. The while loop continues displaying data
Tutorial: Creating a servlet that updates a guestbook
17-17
while the cursor is in bounds, that is while the inBounds() method reports
that the navigation falls between the first and last record visible to the
cursor. When this condition is not met, the table and the HTML page are
closed.
while (dm.getQueryDataSet1().inBounds()) {
out.print("<tr>");
for (int i = 1; i < columns.length; i++) {
out.print ("<td>" + dm.getQueryDataSet1().format(i) + "</td>");
out.println("</tr>");
dm.getQueryDataSet1().next();
}
out.println("</table>");
out.println("</body>");
out.println("</html>");
This code opens the dataset. The dataset must be open before you can
insert or save data. In the data module, the dataset is opened right after
the code that connects to the database and sets up the query.
3 Add code for the method that inserts a new row. To add a row, you need
to create a DataRow object, then pass data from the userName and userComment
parameters into the DataRow. Youll add this method after the jbInit()
method. Simply move the cursor down a line, past the methods closing
curly brace, and press Enter a few times. Add the following method:
public void insertNewRow(String userName, String userComment) {
try {
DataRow dataRow1 = new DataRow(queryDataSet1, new String[]
{ "Name", "Comment"});
dataRow1.setString("Name", userName);
dataRow1.setString("Comment", userComment);
queryDataSet1.addRow(dataRow1);
}
17-18
The first line of the method creates a new DataRow object that holds the
new Name and Comment values. The second and third rows pass the
values in the userName and userComment parameters into the Name and
Comment fields. The last row adds the DataRow object to the dataset.
4 Add the following method to save the new row to the dataset after the
insertNewRow() method:
public void saveNewRow() {
try {
database1.saveChanges(queryDataSet1);
}
catch (DataSetException ex) {
ex.printStackTrace();
}
}
5 Click the Save All icon on the toolbar to save your work.
You have now added all the code to the program. In the next step, youll
compile and run it.
17-19
17-20
5 Click OK to close the Type Or Choose URI To Launch dialog box. The
Runtime Configuration Properties dialog box should look similar to
this:
17-21
4 Type MyName in the Name field and MyComment in the Comment field.
5 Click the Submit button.
The Guestbook SIGNATURES table is rendered in HTML. MyName and
MyComment are displayed in the last row of the table. Note that the URI
has changed to http://localhost:8080/guestbook/table, indicating that
the program is running DBServlet.
For more information on URLs, URIs, and servlets, see How URLs run
servlets on page 10-9.
17-22
6 You can click the back arrow to the left of the URL Location field to
return to the input form and enter another name and comment.
7 Click the Reset Program button directly above the web server tab to
stop the web server. You must stop the web server before you compile
and run the servlet again, after making changes.
Note
17-23
17-24
Chapter
18
Tutorial: Creating a JSP using
the JSP wizard
Chapter18
Web Development is a
feature of JBuilder
Enterprise
This tutorial walks you through developing a JavaServer Page (JSP) using
JBuilders JSP wizard. This JSP takes text input, displays the text as output
when the Submit button is clicked, and uses a JavaBean to count the
number of times the web page is visited.
The JSP wizard is a good starting point for developing JSPs. It doesnt
generate a complete application, but it does take care of all the tedious
details required to get your application up and running. You get to this
wizard by selecting New from the File menu, clicking the Web tab, then
selecting JavaServer Page. For complete information on the options in the
JSP wizard, see the topic on the JSP wizard in the online help.
For development testing purposes in this tutorial, youll use Tomcat. This
tutorial uses Tomcat because it is included with JBuilder and does not
require additional setup. Tomcat is the reference implementation of the
Java Servlet and JavaServer Pages Specifications. This implementation can
be used in the Apache Web Server as well as in other web servers and
development tools. For more information about Tomcat, check out
http://jakarta.apache.org.
This tutorial assumes you are familiar with Java and with the JBuilder
IDE. For more information on Java, see Getting Started with Java. For more
information on the JBuilder IDE, see The JBuilder environment in
Introducing JBuilder.
See the Tutorials section in the JBuilder Quick Tips for useful information
about viewing and printing tutorials. The Accessibility options section in
the JBuilder Quick Tips contains tips on using JBuilder features to
improve JBuilders ease of use for people with disabilities.
18-1
1 Select File|New.
2 Click the Web tab. Select Web Application.
3 Click OK. The Web Application wizard appears.
4 Enter a name for the WebApp, such as jspwebapp. The Directory field is
automatically filled in with the same name.
18-2
5 Leave the default setting for Build WAR, although you wont really
need a WAR file since you probably wont want to actually deploy this
tutorial application.
6 Leave all the JSP/Servlet frameworks unselected and dont specify a
Launch URI.
The wizard should look something like this:
1 Select File|New.
2 Click the Web tab. Select JavaServer Page.
3 Click OK. The JSP wizard appears.
4 In the Name field, enter JSPWithCounter. This is the name of the JSP.
18-3
5 Check Generate Sample Bean and uncheck Generate Error Page. The
wizard looks similar to this:
6 Click Next.
7 Check Generate Submit Form. The wizard looks similar to this:
8 Click Finish to accept all the default settings on the remaining pages of
the wizard.
A JSPWithCounter.jsp file is added to the root directory of your WebApp.
Expand the Root Directory node in the project pane to see it. A
JSPWithCounterBean.java sample bean is also added to your project. This
bean is called by the JSP. The JSP wizard also automatically creates a
runtime configuration so that the JSP can be run in the IDE. For more
information about runtime configurations, see Setting runtime
configurations in Building Applications with JBuilder. For more
information about creating a run configuration with a wizard, see
Creating a runtime configuration with the wizards on page 10-2.
18-4
18-5
18-6
The project compiles and runs. Compilation errors are displayed in the
message pane. If there are errors, refer to Web debugging your servlet or
JSP on page 10-17.
If there are no errors, the web server is started and two new tabs, the Web
View and Web View Source, appear in the content pane. Tomcat, which is
installed with JBuilder, is a servlet engine that supports servlets and JSP
files. The web view is a web browser which displays output from the
running JSP. The Web View Source tab displays the actual HTML code
which has been dynamically generated by the JSP. If successful, the
running JSP looks like this:
Figure 18.2 JSP in web view
The web view of the content pane displays the JSP. For local testing, the URL
points to localhost:8080, which is where Tomcat is running. To test the JSP:
18-7
JSPs are compiled to servlets. In JBuilder, you can debug Java code
snippets in the original JSP file, as opposed to debugging the
corresponding generated Java servlet. For more information on
debugging your JSP, see Web debugging your servlet or JSP on
page 10-17.
18-8
Chapter
19
Tutorial: Creating a servlet with
InternetBeans Express
Chapter19
Web Development is a
feature of JBuilder
Enterprise
This tutorial teaches you how to build a servlet using InternetBeans. When
you are finished with the tutorial, you will have a servlet which uses a
DataModule to query a table in a JDataStore, displays guest book comments
in an IxTable, and allows visitors to the site to enter their own comments
and see them displayed in the guest book. A finished version of the
application created in this tutorial can be found in
<JBuilder>/samples/WebApps/guestbook.
This tutorial assumes you are familiar with Java and Java servlets, the
JBuilder IDE, and JDataStore. For more information on Java, see Getting
Started with Java. For more information on Java servlets, see Chapter 4,
Working with servlets. For more information on the JBuilder IDE, see
The JBuilder environment in Introducing JBuilder. For more information
on JDataStore, see JDataStore Developers Guide.
See the Tutorials section in the JBuilder Quick Tips for useful information
about viewing and printing tutorials. The Accessibility options section in
the JBuilder Quick Tips contains tips on using JBuilder features to
improve JBuilders ease of use for people with disabilities.
For information on documentation conventions used in this tutorial and
other JBuilder documentation, see Documentation conventions on
page 1-4.
19-1
1 Select File|New.
2 Click the Web tab of the object gallery. Select Web Application.
3 Click OK. The Web Application wizard appears.
4 Enter a name for the WebApp, such as guestbookapp. The Directory field
is automatically filled in as you type.
5 Leave the default setting for Build WAR, although you wont really
need a WAR file since you probably wont want to actually deploy this
tutorial application.
6 Check the InternetBeans Express 1.1 JSP/Servlet framework. Dont
specify a Launch URI.
19-2
8 Click OK.
A WebApp node, guestbookapp, is displayed in the project pane. Expand
the node to see the Root Directory and Deployment Descriptors nodes.
Figure 19.1 WebApp node in project pane
1 Select File|New.
2 Click the Web tab of the object gallery. Select Servlet.
3 Click OK. The Servlet wizard appears.
4 Enter a name for the class: SignatureServlet
19-3
5 Select guestbookapp for the WebApp, if its not already selected. The
wizard should look something like this:
19-4
1 Select File|New.
2 Select Data Module from the General page of the object gallery.
3 Click OK. The Data Module wizard appears.
4 Leave the Package and Class Name fields set to the defaults.
5 Make sure the Invoke Data Modeler option is checked.
6 Click OK. The Data Modeler appears.
7 Go to the Database menu and select Add Connection URL.
8 Select com.borland.datastore.jdbc.DataStoreDriver from the driver
drop-down list.
9 In the URL field, enter or browse to the path to the guestbook.jds file. Its
found in the <JBuilder>/samples/WebApps/guestbook folder. Click OK to
close the Create URL for Datastore dialog box.
10 Click OK again. The new Database URL is added to the Database URLs
list on the lower left of the Data Modeler and is selected.
11 Double-click the URL and enter user in the login dialog box. A
password isnt necessary. Click OK to close the dialog box.
12 Open the list of tables by clicking the Tables node of the Available
Columns tree.
13 Select the SIGNATURES table by clicking it.
19-5
14 Click the Copy All button. The Data Modeler should look similar to
this:
19-6
9 Type the following HTML code into the file. You can also copy and
paste it from this tutorial.
<html>
<head>
<title>Guestbook Signatures</title>
</head>
<body>
<h1>Sign the guestbook</h1>
<table id="guestbooktable" align="CENTER" cellspacing="0"
border="1" cellpadding="7">
<tr>
<th>Name</th><th>Comment</th>
</tr>
<tr>
<td>Leo</td><td>I rule!</td>
</tr>
</table>
<form method="POST">
<p>Enter your name:</p>
<input type="text" id="Name" name="Name" size="50">
<p>Enter your comment:</p>
<input type="text" id="Comment" name="Comment" size="100">
<p>
<input type="submit" name="submit" value="Submit"></p>
</form>
</body>
</html>
Notice that the <table> tag contains dummy data. This data will be
replaced with live data from the JDataStore when the servlet is run.
This dummy data provides an indication of how the live data should
look when it is rendered. For more information on how InternetBeans
Express renders tables, see Generating tables on page 7-6.
19-7
11 Click the View tab. The HTML should look like this in the View:
5 Click OK. A line of code is added to the jbInit() method to associate the
DataModule with the servlet.
19-8
Value
dataModule
DataModule11
htmlFile
6 Select the IxControl icon in the palette. Drop three IxControls into the
servlet by clicking in the designer.
Tip
7 Select ixControl1 and set its properties as follows in the order shown:
Property
Value
dataSet
Signatures
columnName
Name
pageProducer
ixPageProducer1
controlName
Name
19-9
Value
dataSet
Signatures
columnName
Comment
pageProducer
ixPageProducer1
controlName
Comment
9 Select the IxTable icon from the palette. Drop an IxTable into the servlet
by clicking in the designer.
10 Set the properties of ixTable1 as follows:
Property
Value
pageProducer
ixPageProducer1
dataSet
Signatures
elementId
guestbooktable
Value
pageProducer
ixPageProducer1
controlName
submit
12 Click the Events tab in the property inspector. The UI should look
similar to this:
19-10
When the form is posted, this code gets a per-session instance of the
DataModule, inserts an empty row, calls IxPageProducer.servletPost() to
fill in the empty row with the values the user typed, then calls doGet()
again to display the data that was posted.
This code gets a per-session instance of the DataModule and posts and
saves the users input to the JDataStore. Note that this per-session
instance is different from the shared instance stored in the variable
dataModule11.
19-11
5 Click OK.
19-12
name and comment are displayed in the table and saved to the
JDataStore.
4 Stop the servlet by clicking the Reset Program button on the Web
Server tab in the message pane.
19-13
19-14
Chapter
20
Tutorial: Creating a JSP with
InternetBeans Express
Chapter20
Web Development is a
feature of JBuilder
Enterprise
20-1
20-2
7 Click OK.
A WebApp node, jspixwebapp is displayed in the project pane. Expand the
node to see the Root Directory and Deployment Descriptors nodes.
Figure 20.1 WebApp node in project pane
1 Select File|New.
2 Click the Web tab. Select JavaServer Page.
3 Click OK. The JSP wizard appears.
4 In the name field, enter a name for the JSP: GuestbookJSP
5 Uncheck Generate Sample Bean.
20-3
6 Click Next.
7 Uncheck Generate Submit Form.
8 Check internetbeans under InternetBeans Express 1.1 in the Tag
Libraries tree.
The JSP Wizard should look similar to this:
20-4
1 Open the GuestbookJSP.jsp file in the editor, if its not already open. Its
in the Root Directory node of the WebApp in the project pane.
2 Change the contents of the <title> tag to read JSP/InternetBeans
Tutorial.
3 Change the contents of the <h1> tag to read Sign the Guestbook
4 Type the following HTML code into the body of the file, below the </h1>
tag:
<table id="guestbooktable" align="CENTER" cellspacing="0"
border="1" cellpadding="7">
<tr>
<th>Name</th><th>Comment</th>
</tr>
<tr>
<td>Leo</td><td>I rule!</td>
</tr>
</table>
<form method="POST">
<p>Enter your name:</p>
<input type="text" name="Name" size="50">
<p>Enter your comment:</p>
<input type="text" name="Comment" size="100">
<p>
<input type="submit" name="submit" value="Submit"></p>
</form>
20-5
When you are finished, the HTML should look like this in the View tab:
1 If you switched to the View tab in the previous step, switch back to the
editor.
2 Add the opening database tag shown in bold. Change the value of the
url attribute of the database tag to point to the guestbook.jds JDataStore
in <jbuilder>\samples\WebApps\guestbook.
<h1>
Sign the guestbook
</h1>
<ix:database id="database1"
driver="com.borland.datastore.jdbc.DataStoreDriver"
url="jdbc:borland:dslocal:jbuilder\\samples\\WebApps\\guestbook\\
guestbook.jds"
username="user">
<table id="guestbooktable" align="CENTER" cellspacing="0"
border="1" cellpadding="7">
Note that you are nesting the query tag within the database tag. This is so
that the database attribute of the query tag doesnt need to be specified,
since its implied. It also makes the code more elegant.
20-7
Note that you are wrapping the HTML table tag in the InternetBeans
table tag. This allows the InternetBeans IxTable to implicitly understand
which table it is replacing. The InternetBeans table tag is nested within
the InternetBeans query tag. This isnt required, because the tables
dataSet attribute makes the relationship clear. Nesting the
InternetBeans table within the query tag like this just makes the code
more elegant.
Note that you are wrapping each of the HTML text input tags in an
InternetBeans control tag. This allows the InternetBeans IxControls to
implicitly understand which text input fields they are replacing.
Click the Save All button on the toolbar.
20-8
Note that you are wrapping the HTML submit input tag in an
InternetBeans submit tag. This allows the InternetBeans IxSubmitButton to
implicitly understand which submit button it is replacing.
Click the Save All button on the toolbar.
20-9
This last Java code fragment may look a little confusing, because it doesnt
appear to be enclosed in a method declaration. It actually is. When the JSP
gets compiled this will become part of the service() method in the
generated servlet (which you cant see, but its still there). Any line of code
within a JSP scriptlet tag such as this will become part of the service()
method.
This code fragment inserts a row in the dataset just before the form is
displayed. The form displays empty values. Then when the form is posted
the data is written to the empty row before calling the submitPerformed()
method.
Click the Save All button on the toolbar.
20-10
9 Make sure the dependencies for the following libraries are set to
Include All:
InternetBeans Express
dbSwing
Data Express
JDataStore Server
10 If any of these libraries are not set to Include All, select the library, then
select the Always Include All Classes And Resources radio button. The
text next to the library name changes to Include All. Once all the library
dependencies are set correctly click OK.
Click the Save All button on the toolbar.
1 Make sure the Root Directory node of the WebApp is expanded in the
project pane.
2 Right-click GuestbookJSP.jsp in the project pane.
3 Select Web Run Using "GuestbookJSP" from the menu.
Tomcat is started and the JSP runs within the JBuilder IDE.
Note
4 Select the URL shown at the top of the Web View and copy it. Paste it
into the URL field in the full-featured browser of your choice and go to
the URL.
Note
5 Enter your name and comment in the JSP running in your external
browser.
6 Click the Submit button in the external browser. Your name and
comment are added to the table (and stored in the JDataStore).
20-11
20-12
Chapter
21
Tutorial: Running the
CheckBoxControl sample
application with Java Web Start
Chapter21
Tutorial: Running the CheckBoxControl sample application with Java Web Start
21-1
21-2
7 Make sure only the JSP/Servlet service is selected in the Services list on
the left side of the dialog box.
The Server page, with the JSP/Servlet service selected, looks like this:
Tutorial: Running the CheckBoxControl sample application with Java Web Start
21-3
21-4
6 Click Finish to create the archive and close the wizard. You do not need
to change any options on the remaining steps of the wizard.
7 Choose File|Save All.
8 Choose Project|Make Project CheckBoxControl.jpx to create the JAR
file.
The wizard creates an archive node and displays it in the project pane. The
archive will be built each time you build the project.
Tutorial: Running the CheckBoxControl sample application with Java Web Start
21-5
If the name entered in the Name field matches the name of an existing
HTML or JNLP file in your project, you are asked if you want to
overwrite the existing file.
The Enter Required Information page of the Web Start Launcher
wizard looks like this:
8 Click Next.
21-6
9 Enter CheckBox Sample in the Title field. Enter Borland in the Vendor field
and Web Start Sample in the Description field. Make sure the Allow
Offline Usage option is not selected.
The Enter Descriptive Information page of the Web Start Launcher
wizard looks like this:
10 Click Finish.
The wizard creates an HTML file and a JNLP file called
CheckBoxControlLauncher and places them in root directory of your web
application. To see these files in the project pane, expand the Root
Directory node of the checkboxcontrol WebApp node.
The project pane should look similar to this:
Note
You can open these files in the editor; however, do not change them.
Tutorial: Running the CheckBoxControl sample application with Java Web Start
21-7
21-8
9 The Runtime Configuration Properties dialog box will look like this:
Tutorial: Running the CheckBoxControl sample application with Java Web Start
21-9
JBuilder displays a warning message in the web view. The web view
looks like this:
2 Position the cursor in the Location field of your external browser and
press Ctrl+V. This copies the Web Run URL from the clipboard. JBuilder
copied this URL into the clipboard, based on your selection on the Web
page of the IDE Options dialog box. (You selected this option in an
earlier step of this tutorial.) Press Enter to go to the URL.
Important
3 Click the link on the web page. Java Web Start loads and launches the
application. The application is now running from a link in an external
web browser. Note that the splash screen displays information you
entered into the Web Start Launcher wizard.
4 Choose File|Exit to exit the sample application. To stop the web server,
choose the Reset Program button on the Web Server tab.
21-10
In this tutorial, you learned how to set up a project for a Web Start
application, use the Web Start Launcher wizard to create the applications
homepage and JNLP file, and launch the application with Web Start.
Tutorial: Running the CheckBoxControl sample application with Java Web Start
21-11
21-12
Index
A
Action class 8-1, 8-8
and struts-config.xml 8-8
Action Mappings page
Struts Config Editor 13-11
Action wizard 8-8
ActionForm class 8-1, 8-6, 8-10
and struts-config.xml 8-6
ActionForm wizard 8-6
action-mappings element
struts-config.xml 13-11
ActionServlet class 8-1
applet deployment 14-8, 14-12
in archives 14-9
applet runtime configurations 10-2
creating with Run|Configurations 10-3
creating with wizard 10-2
applet security
restrictions 14-10
sandbox 14-10
security manager 14-2, 14-10
signing 14-11
solutions 14-11
applet tag 14-2
attributes 14-3
mistakes 14-4
Applet wizard 14-16
applets 14-1
archiving 14-9
browser issues 14-5, 14-7
browser Java implementation 14-6
debugging 14-21
debugging in a browser 14-22
in a WAR file 3-15
Java Plug-in 14-7
Java Virtual Machine 14-2
Java Web Start 14-7
overview 2-6, 14-2
running 14-19
running JDK 1.1.x applets in JBuilder 14-20
running JDK 1.2 14-21
testing 14-13
third-party libraries 14-12
tips 14-8
using packages 14-9
AppletTestbed 14-20
debugging applets 14-21
appletviewer 14-20
debugging applets 14-21
application homepage
Web Start 15-6
archive attribute, applet tag 14-3
archive file
deploying to a web server 11-1
authentication
for a WebApp 12-15
B
Borland
contacting 1-5
developer support 1-5
e-mail 1-7
newsgroups 1-7
online resources 1-6
reporting bugs 1-7
technical support 1-5
World Wide Web 1-6
browsers
difference in Java implementation 14-6
invoking servlets from 5-11
Java Plug-in 14-7
JDK support issues 14-5
running applets 14-5
solutions for running applets 14-7
C
case sensitivity
in applets and applet tag 14-9
CGI (Common Gateway Interface)
compared to servlets 2-2
Classes page
of WebApp properties 3-10
client requests to servlet 4-6
code attribute, applet tag 14-3
codebase attribute, applet tag 14-3
Common Gateway Interface (CGI)
compared to servlets 2-2
compiling
applets 14-19
JSP 6-11, 10-13
servlets 10-13
Configure Libraries dialog box 6-6
configuring
libraries 6-6
configuring web server 9-1
control tag, InternetBeans Express 7-8
Index
I-1
D
Data Sources page
Struts Config Editor 13-3
data-aware
JSP 7-1
servlets 5-13, 7-1
Database class
using in a JSP 7-8
using in a servlet 7-3
database tag, InternetBeans Express 7-8
DataExpress
using in a JSP 7-1, 7-6
using in a servlet 7-1, 7-3
data-source element
struts-config.xml 13-3
debugging
applets 14-21
applets in a browser 14-22
Dependencies page
of WebApp properties 3-12
deploying
applet archive files 14-9
applets 14-8, 14-12
applications 15-1
archive file 11-1
by file type 3-13
JSP 11-3
servlets 4-8, 11-2
WAR file 11-1
WebApp 11-1
deployment descriptors
editing 3-2
for a WebApp 3-5
more information 11-5
node of WebApp 3-6
Struts Config Editor 13-1
struts-config.xml 13-1
vendor-specific for a WebApp 11-4
web application 11-4
web.xml file 3-6, 12-1
WebApp DD Editor 12-1
directories
of a WebApp 3-8
distributed applications
vs. web applications
documentation conventions 1-4
platform conventions 1-5
E
EJB References page
in WebApp DD Editor 12-13
I-2
F
file locations
in a WebApp 3-5
file types
included in WAR file 3-13
filter
adding to web.xml file 12-2
filter servlets 5-1, 12-4
Filters page
in WebApp DD Editor 12-4
fonts
JBuilder documentation conventions 1-4
Form Beans page
Struts Config Editor 13-5
form-beans element
struts-config.xml 13-5
frameworks 6-5
Cocoon 8-3
Configure Libraries dialog box 8-3
configuring 6-6
InternetBeans 8-3
JSTL 8-3
Struts 8-3
user-defined 6-6
using with JSP 6-4
G
generated URL 10-15
generating tables
with InternetBeans Express 7-6
Global Forwards page
Struts Config Editor 13-8
global-forwards element
struts-config.xml 13-8
H
height attribute, applet tag 14-3
hspace attribute, applet tag 14-3
HTML page
converting to Struts 8-12
invoking servlets from 5-12
HTML servlets 4-7, 5-4
HTTP servlets 4-7
I
image tag, InternetBeans Express 7-8
importing
files to a WebApp 3-5
web application 3-3
installing Web Start 15-3, 15-4
InternetBeans
tutorial 19-1, 20-1
InternetBeans Express 7-1
and JSPs 7-6
and servlets 7-3
displaying servlet data 7-3
format of tag library file 7-9
generating tables 7-6
overview 2-5
parsing HTML 7-5
posting servlet data 7-5
table of classes 7-2
table of JSP tags 7-8
tag library 7-6
using with JSP 6-4
InternetBeans Express tag library
control tag 7-8
database tag 7-8
image tag 7-8
query tag 7-8
submit tag 7-8
table tag 7-8
internetbeans.tld file 7-6
format 7-9
table of JSP tags 7-8
invoking servlets 5-11
IxCheckBox class 7-2
IxComboBox class 7-2
IxControl class 7-2
using in a JSP 7-8
using in a servlet 7-3
IxHidden class 7-2
IxImage class 7-2
using in a JSP 7-8
IxImageButton class 7-2
IxLink class 7-2
IxListBox class 7-2
IxPageProducer class 7-2
servletGet() method 7-3
servletPost() method 7-5
using in a servlet 7-3
IxPassword class 7-2
IxPushButton class 7-2
IxRadioButton class 7-2
IxSpan class 7-2
J
JAR files
applet archive attribute 14-3
including in WAR file 3-15
signing 14-11
Java Network Launching Protocol 15-1
See also JNLP
Java Plug-in 14-7
Java support, browsers 14-5
Java Web Start 15-1
See also Web Start
JavaServer Pages 6-1
See also JSP
JavaServer Pages Standard Tag Library (JSTL) 6-4
JBuilder
working with WebApps 10-1
JNLP 15-1
JNLP file 15-6
JSP
creating from ActionForm 8-10
JSP (JavaServer Pages)
and InternetBeans Express 7-6
and servlets 4-2
compiling 6-11, 10-13
converting to Struts 8-12
creating in wizard 6-9
data-aware 7-1
deploying 11-3
developing 6-9
features of JBuilder 6-5
frameworks 6-4, 6-5
including in WAR file 3-13
InternetBeans Express 6-4
JSTL 6-4
launching 10-5
links 6-12
overview 2-3
run properties 10-12
source debugging 10-17
Struts 6-4
syntax 6-3
tag libraries 6-4
Index
I-3
M
Manifest page
of WebApp properties 3-13
mapping servlets 5-6, 10-2, 10-9
MIME Types page
in WebApp DD Editor 12-11
multi-threaded servlet 4-6
I-4
name attribute
applet tag 14-3
internetbeans.tld file 7-9
naming servlets 5-6, 10-9
newsgroups
Borland 1-7
public 1-7
P
packages
in applets 14-9
param tag, applets 14-3
parameters
applet tag 14-3
Plug-in, Java 14-7
project
selecting web server for 9-4
setting up for Web Start 15-4
properties
of a WebApp 3-6
of WAR file 3-13
Q
query tag, InternetBeans Express 7-8
QueryDataSet class
using in a JSP 7-8
using in a servlet 7-3
S
sandbox
applet security 14-10
Web Start application security 15-2
security
applet restrictions 14-10
applets 14-11
for a WebApp 12-16
for Web Start application 15-2
sandbox 14-10
security manager 14-10
signing applets 14-11
security constraint
adding to web.xml file 12-2
Security page
in WebApp DD Editor 12-16
servlet
tutorial 16-1, 17-1, 19-1
servlet API 4-3
servlet HTTP package 4-4
servlet methods
overriding standard 5-5
servlet parameters 5-8
servlet runtime configurations 5-10, 10-2
configuring runnable file 10-5
creating with Run|Configurations 10-5
creating with wizard 10-2
servlet threads
multi-threaded 4-6
single threaded 5-1
servlet types
filter 5-1, 12-4
listener 5-1, 5-9
standard 5-1
Servlet wizard
options 5-1
ServletContext 3-5
servletGet() method 7-3
servletPost() method 7-5
servlets 4-1, 5-1
adding to web.xml file 12-2
and InternetBeans Express 5-13, 7-3
and JSPs 4-2
and URIs 10-9
and URLs 5-6, 10-9
and web servers 4-1, 4-3
and WebApp 5-1, 5-6, 10-9
client requests 4-6
compared to CGI (Common Gateway
Interface) 2-2, 4-1
compiling 10-13
content type 5-4
creating with wizard 5-1
Index
I-5
T
table tag, InternetBeans Express 7-8
tables
generating with InternetBeans Express 7-6
tag libraries
and JBuilder 8-3
configuring 6-6
importing into JSP 8-6
InternetBeans Express 7-6
JSP 6-4
Struts 8-1, 8-3
using in webapp 8-5
Tag Libraries page
in WebApp DD Editor 12-10
tagclass attribute, internetbeans.tld file 7-9
testing
applets 14-13
third-party libraries
applets 14-12
Tomcat
configuring 9-1
I-6
tutorials
JSP 18-1
JSP and InternetBeans 20-1
servlet 16-1, 17-1
servlet and InternetBeans 19-1
Web Start 21-1
U
URI launching 10-2, 10-5
URIs and servlets 10-9
URL pattern 5-6, 10-9
URLs and servlets 5-6, 10-9
Usenet newsgroups 1-7
user-defined frameworks 6-6
V
vspace attribute, applet tag 14-3
W
WAR file (web archive)
adding applets 3-15
adding JAR files 3-15
compressing 3-7
creating 3-7
definition of 3-13
deploying 11-1
directories to include 3-8
generating 3-3
included file types 3-13
properties 3-13
relation to WebApp 3-13
setting location of 3-7
setting name of 3-7
tools 3-2
viewing contents of 3-13
Web Application wizard 3-3
support for Struts 8-5
web applications 1-1, 2-9, 3-1, 10-1
See also WebApp
in JBuilder
overview
vs distributed applications
working with
web archive 3-2
See also WAR file
web commands
configuring IDE for 9-7
Web Debug command 10-1
JSP 6-12
web debugging
JSP 10-17
servlets 10-17
web development
basic process 2-8
web resource collection
adding to web.xml file 12-2
Web Run command 10-1, 10-14, 10-15, 10-16
JSP 6-12
web running
JSPs 10-14
servlets 10-14
web server
configuring 9-1
formatted output 10-15
raw output 10-16
selecting for project 9-4
starting 10-14
stopping 10-17
Sun iPlanet 9-3
Tomcat 9-1
WebLogic 9-3
WebSphere 9-3
Web Start 15-1
and JBuilder 15-4
applets 14-7
application homepage 15-6
application security 15-2
installing 15-3, 15-4
JAR file 15-6
JNLP file 15-6
modifying library definition 15-4
setting up project for 15-4
tutorial 21-1
wizard 15-6
web view 10-15
web view source 10-16
web.xml file 11-4
adding a filter 12-2
adding a security constraint 12-2
adding a servlet 12-2
adding a web resource collection 12-2
and Struts 8-14
and struts-config.xml 8-14
authentication method 12-15
creation of 3-6
editing 3-2, 12-1
EJB references 12-13
environment entries 12-12
error page mapping 12-12
filter-mapping tags 12-4
listener tags 12-6
local EJB references 12-14
MIME Type mapping 12-11
Index
I-7
I-8
wizards
Applet 14-16
JSP (JavaServer Page) 6-9, 7-6
servlet 5-1
Web Application 3-3
WML servlets 5-4
X
XHTML servlets 5-4
XML servlets 5-4
Z
ZIP files
applet archive attribute 14-3