a >
2. If the resource is on the same server, but is not descended from the current
directory, then include the full path from the document root, starting with
a
/
.
<
a href=”/path/from/root/page.html”>
Some Page on the Current Server
a >
3. If the resource is in the same directory as the HTML page that references it,
then only include the fi le name, not the server or the directory.
<
a href=”page.html”>
Some Page
a >
4. If the resource is in a subdirectory of the directory where the HTML page that
references it is located, then include the name of the subdirectory and the fi le
name.
<
a href=”subdir/of/current/dir/page.html”>
Some Page in Some Subdir
a >
12
Web Development with Java
There are three types of references.
1. Absolute
2. Relative from document root
3. Relative from current directory
There are just a few rules to determine the kind of reference.
1. If the URL begins with a protocol (like http://, ftp://, or telnet://), then it is an
absolute reference to that location.
2. If the URL begins with a /, then it is a relative reference from the document
root of the current server.
3. In all other cases, the URL is a relative reference from the current directory.
1.3 HTML
Forms
If you have ever logged into a web site, then you have used an HTML form to
supply your username and password. A form will have places where a user can
enter data. These are known as
form elements and can be for one line of text,
several lines of text, drop down lists and buttons. The form in Figure 1.6, which is
from Florida International University, uses several form elements for lines of text
and a button for submitting the data to the server.
1.3.1 Form
Elements
The form and the form elements are defi ned using HTML tags. The opening form
tag is
. Plain text, other HTML tags and
form element tags can be placed between the opening and closing form tags. There
are many form elements, but only two of them will be introduced now. Table 1.3
Figure 1.6
An entry form from FIU.
Table 1.3
Two essential form element types.
Type Example
text
The
value attribute is the text that appears within the element when the page is loaded.
submit
The
value attribute is the text that appears on the button in the browser.
Browser – Server Communication
13
defi nes the two essential form elements:
text and
submit . Additional form elements
are covered in Chapter Six.
Each of these has the same tag name (
input ) and attributes (
type ,
name ,
value ).
1. The HTML tag name is
input .
2. There are many different form elements that use the
input tag. The
type attri-
bute identifi es which form element to display.
3. There could be several form elements in a form. The
name attribute should be
a unique identifi er for the element.
4. The
value attribute stores the data that is in the element. The value that is hard
coded in the element is the value that is displayed in the browser when the
HTML page is loaded.
5. The
name and
value attributes are used to send data to the server. When the
form is submitted, the data for this element will be sent as
name =
value .
The value that will be sent will be the current data that is displayed in
the element.
Listing 1.2 is an example of a simple web page that has a form in it.
<