We provide here a very brief tutorial on creating and posting web
pages. For a full introduction to web page programming, look for
one of the many books or on line courses on the topic.
Hypertext Code
A web page contains a special text based language called hypertext
markup language or HTML. The browser interprets the special
hypertext code to determine how to display the text, graphics, tables,
etc.
The essential element in hypertext is the tag, which provide
instructions on form and function. Tags are enclosed in angle brackets:
<> and each
tag has a corresponding matching tag with a a backslash, </>,
to indicate the end of the tag operation. For example,
<b>
Hello </b>
indicates that the text "Hello" will be displayed in
bold: Hello
The following hypertext shows the hypertext for simple web page
code :
webpage.html |
<HTML>
<HEAD>
<TITLE> A Simple Program </TITLE>
</HEAD>
<BODY>
<b> Learning Java </b> <br>
Java is a trademark of <a href="http://java.sun.com">Sun
Microsystems</a>
</BODY>
</HTML>
|
We see first that the entire code is enclosed in
the <HTML>
- </HTML> matching tags. A header section is enclosed
in <HEAD>
- </HEAD> and so forth.
White space, such as line returns, are ignored by
the browser. Instead, you must include tags to create a line return.
Here we see the <Br>
tag, which causes a line return. It is one of the few tags that
does not require a matching right tag.
A web link is created with the
<a
href = "URL web address"> text to link </a>
set of tags, where "web address" indicates
the Universal Resource Link (URL) address of the web page
to link. Here we see a common property of many types of tags in
which an attribute is included inside of the left tag.
If you open the file webpage.html
in your browser, the above hypertext code will produce a web page
that looks something like this:
You can choose different background colors, a color
for links, etc. with attributes of the <body>
tag. See a hypertext reference for information on this tag and
others.
Note that the hypertext is typically stored in a
file whose name is appended with the .html
or .htm
suffix.
Editing Web Pages
You can edit the hypertext code directly as shown
above. However, most people use a hypertext graphical editor of
some kind in which you edit the text, images, tables, etc in a what-you-see-is-what-you-get
(WYSIWYG) approach. That is, the page that you edit looks very similar
to the way it will appear in the browser; you don't see the underlying
hypertext tags.
If you intend to do extensive web development, you
need to know the details of hypertext tags to fix bugs and tune
the code to your desired look. For routine web page creation, however,
you will want to use a hypertext editor.
Many commercial and free web editors are available.
The Netscape browser, for example, provides a free web editor (called
Composer).
Posting Web Pages
Once you have your hypertext file, you must place it on a computer
that is accessible from the web and that runs a program called a
web server. The web server receives requests for files from
browsers on the Internet and then sends the files to the requesters.
(We will actually show how to create a simple web (or HTTP) server
in Chapter 14.
The server obviously needs to know where to find a requested file.
If you are developing your programs on a school or work computer
that's on the net and runs its own web server, then your system
manager will typically provide a directory where you should place
your hypertext files.
On a Unix system, for example, you will typically create a sub-directory
called public_html
where you put your hypertext and Java class files. The system
manager will set up the server so that it will look in that directory
when it obtains a request for your file webpage.html:
http://www.your-department.edu/~yourAccountName/webpage.html
If instead of a local server machine, you are planning to post
your pages on a remote web site, you will need to up load
your web pages to that site. For example, perhaps you obtained a
web site via your dial up account or on one of the free web hosting
sites.
In this case, you typically use an ftp (File Transport Protocol)
program (or use the ftp capability in your browser) to copy the
hypertext and applet class files from your machine to the host's
site. The host service should provide directions (what username/password
to use, for example) on how to do this for their system.
Latest update: Dec.10.2003
|