Databases Reference
In-Depth Information
search is in process. All quotations are retrieved from the database, and
inQuote() determines if the keyword is found. If it is, the quotation is
returned (with the keyword portion highlighted in yellow), and the search
process goes on until the entire database is examined. Meanwhile, the cli-
ent gets the perception that the page is still loading. When the servlet is
done executing, some summary statistics are returned. I promise not to
scrutinize the code any further (since you can examine it as well as I can).
Suffice it to say that this search is slow and could be significantly improved
in a couple of ways: if a keyword appears as part of word, the keyword por-
tion is highlighted; if it appears twice in a fortune, only the first occurrence
is highlighted. These are areas for improvement that I'll leave as an exer-
cise for the reader. Exhibit 34-13 shows two screen captures of what you
should expect the QuoteSearch servlet to return.
QUICK SETUP
Installation of the servlet SDK will create a JSDK2.0 directory and subdi-
rectories for documentation ( doc ), executable programs ( bin ), library files
( lib ), and source code ( src ). You'll find the servletrunner utility in the bin
directory. You configure this program, i.e., associate a servlet name and its
compiled class file, by modifying the servlet.properties file in a text editor.
Examples of how to use this file are illustrated in Exhibit 34-14.
Writing your own servlets requires two more things: all your programs
must import the javax.servlet and javax.servlet.http packages, and you must
start the servletrunner utility after you've edited the servlet.properties file.
The easiest way to import the packages into your programs is by modifying
your CLASSPATH setting as follows:
SET CLASSPATH = %CLASSPATH%;C:\jsdk2.0\lib\jsdk.jar
This will allow you to use the javac compiler without error, and the only
thing left to do is to start the servletrunner utility. You can do this by simply
typing the name of the program at a DOS command prompt, or you can
append a number of parameters to customize its configuration. Exhibit 34-15
shows you what command-line parameters are available.
CONCLUDING REMARKS
Servlets are a useful extension to the Java programming language that
have almost the identical functionality and utility of CGI programs, but
unlike the latter, they are not as prone to security risks and are much easier
to write. This chapter has demonstrated how you can rapidly develop and
deploy a three-tier client/server RDBMS application using this technology.
If you have specific questions that you cannot find answers to after consult-
ing the resources listed below, you may contact the author via e-mail at
jsheld@hotmail.com.
Search WWH ::




Custom Search