📄 tij0028.html
字号:
<html><body>
<table width="100%"><tr>
<td>
<a href="http://www.bruceeckel.com/javabook.html">Bruce Eckel's Thinking in Java</a>
</td>
<td align="right">
<a href="tij_c.html">Contents</a> | <a href="tij0027.html">Prev</a> | <a href="tij0029.html">Next</a>
</td>
</tr></table>
<hr>
<H2 ALIGN=LEFT>
Java
and the Internet
</H2>
<DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">If
Java is, in fact, yet another computer programming language, you may question
why it is so important and why it is being promoted as a revolutionary step in
computer programming. The answer isn’t immediately obvious if
you’re coming from a traditional programming perspective. Although Java
will solve traditional stand-alone programming problems, the reason it is
important is that it will also solve programming problems on the World Wide Web.
</FONT><a name="_Toc375545207"></a><a name="_Toc408018404"></a><P></DIV>
<A NAME="Heading40"></A><H3 ALIGN=LEFT>
What
is the Web?
</H3>
<DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">The
Web can seem a bit of a mystery at first, with all this talk of
“surfing,” “presence” and “home pages.”
There has even been a growing reaction against “Internet-mania,”
questioning the economic value and outcome of such a sweeping movement.
It’s helpful to step back and see what it really is, but to do this you
must understand client/server systems, another aspect of computing that’s
full of confusing issues.
</FONT><P></DIV>
<A NAME="Heading41"></A><H4 ALIGN=LEFT>
Client/Server
computing
</H4>
<DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">The
primary idea of a client/server system is that you have a central repository of
information – some kind of data, typically in a database – that you
want to distribute on demand to some set of people or machines. A key to the
client/server concept is that the repository of information is
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>centrally
located
</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">so
that it can be changed and so that those changes will propagate out to the
information consumers. Taken together, the information repository, the software
that distributes the information and the machine(s) where the information and
software reside is called the
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>server</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.
The software that resides on the remote machine, and that communicates with the
server, fetches the information, processes it, and displays it on the remote
machine is called the
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>client</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">The
basic concept of client/server computing, then, is not so complicated. The
problems arise because you have a single server trying to serve many clients at
once. Generally a database management system is involved so the designer
“balances” the layout of data into tables for optimal use. In
addition, systems often allow a client to insert new information into a server.
This means you must ensure that one client’s new data doesn’t walk
over another client’s new data, or that data isn’t lost in the
process of adding it to the database. (This is called
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>transaction
processing.
</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">)
As client software changes, it must be built, debugged and installed on the
client machines, which turns out to be more complicated and expensive than you
might think. It’s especially problematic to support multiple types of
computers and operating systems. Finally, there’s the all-important
performance issue: you might have hundreds of clients making requests of your
server at any one time, and so any small delay is crucial. To minimize latency,
programmers work hard to offload processing tasks, often to the client machine
but sometimes to other machines at the server site using so-called
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>middleware</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.
(Middleware is also used to improve maintainability.)
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">So
the simple idea of distributing information to people has so many layers of
complexity in implementing it that the whole problem can seem hopelessly
enigmatic. And yet it’s crucial: client/server computing accounts for
roughly half of all programming activities. It’s responsible for
everything from taking orders and credit-card transactions to the distribution
of any kind of data – stock market, scientific, government – you
name it. What we’ve come up with in the past is individual solutions to
individual problems, inventing a new solution each time. These were hard to
create and hard to use and the user had to learn a new interface for each one.
The entire client/server problem needs to be solved in a big way.
</FONT><P></DIV>
<A NAME="Heading42"></A><H4 ALIGN=LEFT>
The
Web as a giant server
</H4>
<DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">The
Web is actually one giant client-server system. It’s a bit worse than
that, since you have all the servers and clients coexisting on a single network
at once. You don’t need to know that, since all you care about is
connecting to and interacting with one server at a time (even though you might
be hopping around the world in your search for the correct server).
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Initially
it was a simple one-way process. You made a request of a server and it handed
you a file, which your machine’s browser software (i.e. the client) would
interpret by formatting onto your local machine. But in short order people
began wanting to do more than just deliver pages from a server. They wanted
full client/server capability so that the client could feed information back to
the server, for example, to do database lookups on the server, to add new
information to the server or to place an order (which required more security
than the original systems offered). These are the changes we’ve been
seeing in the development of the Web.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">The
Web browser was a big step forward: the concept that one piece of information
could be displayed on any type of computer without change. However, browsers
were still rather primitive and rapidly bogged down by the demands placed on
them. They weren’t particularly interactive and tended to clog up both
the server and the Internet because any time you needed to do something that
required programming you had to send information back to the server to be
processed. It could take many seconds or minutes to find out you had misspelled
something in your request. Since the browser was just a viewer it
couldn’t perform even the simplest computing tasks. (On the other hand,
it was safe, since it couldn’t execute any programs on your local machine
that contained bugs or viruses.)
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">To
solve this problem, different approaches have been taken. To begin with,
graphics standards have been enhanced to allow better animation and video
within browsers. The remainder of the problem can be solved only by
incorporating the ability to run programs on the client end, under the browser.
This is called
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>client-side
programming
</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.</FONT><a name="_Toc408018405"></a><P></DIV>
<A NAME="Heading43"></A><H3 ALIGN=LEFT>
Client-side
programming
<A NAME="fnB8" HREF="#fn8">[8]</A></H3>
<DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">The
Web’s initial server-browser design provided for interactive content, but
the interactivity was completely provided by the server. The server produced
static pages for the client browser, which would simply interpret and display
them. Basic HTML contains simple mechanisms for data gathering: text-entry
boxes, check boxes, radio boxes, lists and drop-down lists, as well as a button
that can only be programmed to reset the data on the form or
“submit” the data on the form back to the server. This submission
passes through the
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>Common
Gateway Interface
</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
(CGI) provided on all Web servers. The text within the submission tells CGI
what to do with it. The most common action is to run a program located on the
server in a directory that’s typically called “cgi-bin.” (If
you watch the address window at the top of your browser when you push a button
on a Web page, you can sometimes see “cgi-bin” within all the
gobbledygook there.) These programs can be written in most languages. Perl is a
common choice because it is designed for text manipulation and is interpreted,
so it can be installed on any server regardless of processor or operating system.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Many
powerful Web sites today are built strictly on CGI, and you can in fact do
nearly anything with it. The problem is response time. The response of a CGI
program depends on how much data must be sent as well as the load on both the
server and the Internet. (On top of this, starting a CGI program tends to be
slow.) The initial designers of the Web did not foresee how rapidly this
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -