Database Reference
In-Depth Information
• How to use each of our API languages to write a short web script that queries the
MySQL server and displays the results in a web page.
• How to properly encode output. HTML consists of text to be displayed interspersed
with special markup constructs. If the text contains special characters, you must
encode them to avoid generating malformed web pages. Each API provides a way
to do this.
The following chapters go into more detail on topics such as displaying query results
in various formats (paragraphs, lists, tables, and so forth), working with images, form
processing, and tracking a user across the course of several page requests as part of a
single user session.
This topic uses the Apache web server for Perl, Ruby, PHP, and Python scripts. It uses
the Tomcat server for Java scripts written using JSP notation. Apache and Tomcat are
available from the Apache Software Foundation .
Recipe 18.2 discusses how to configure Apache for Perl, Ruby, PHP, and Python, and
how to write a short web script in each language. Recipe 18.3 discusses JSP script writing
using Tomcat. Because Apache installations are prevalent, I assume that it's already
installed on your system and you just need to configure it. Tomcat is less frequently
preinstalled; for additional installation and setup information, read “JSP, JSTL, and
Tomcat Primer” on the compnaion website (see the Preface ). You can use servers other
than Apache and Tomcat, if you adapt the instructions given here.
Scripts for examples in this chapter are located in the recipes distribution under the
directories named for the servers used to run them. For Perl, Ruby, PHP, and Python
examples, look under the apache directory. For Java (JSP) examples, look under the
tomcat directory.
I assume here that you have some basic familiarity with HTML. For Tomcat, it's also
helpful to know something about XML because Tomcat's configuration files are written
as XML documents, and JSP pages contain elements written using XML syntax. In
general, the web scripts in this topic produce output that is valid not only as HTML,
but as XHTML, the transitional format between HTML and XML. (That's another rea‐
son to be familiar with XML.) For example, XHTML requires closing tags, so paragraphs
are written with a closing </p> tag following the paragraph body. Uses of this output
style will be obvious for scripts written using languages like PHP in which the HTML
tags are included literally in the script. For interfaces that generate HTML for you,
XHTML conformance is a matter of whether the module itself produces XHTML. For
example, the Perl CGI.pm module generates XHTML; the Ruby cgi module does not.
Search WWH ::




Custom Search