
		 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		 %	       INTRO		%
		 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Introduction}

% Historical overview
% Strength of LP
%% Safe and sound
%% Term-rewrite facilities (DCG in parse and generate mode)

The Web is an exciting place offering new opportunities to artificial
intelligence, natural language processing and Logic Programming.
Information extraction from the Web, reasoning in Web applications and
the Semantic Web are just a few examples. We have deployed Prolog in Web
related tasks over a long period. As most of the development on
SWI-Prolog takes place in the context of projects that require new
features, the system and its libraries provide extensive support for Web
programming.

There are two views on deploying Prolog for Web related tasks. In the
most commonly used view, Prolog acts as an embedded component in a
general Web processing environment. In this role it generally provides
reasoning tasks such as searching or configuration within constraints.
Alternatively, Prolog itself can act as a stand-alone HTTP server as also
proposed by ECLiPSe \cite{Eclipse-http}. In this view it is a component
that can be part of any of the layers of the popular three-tier
architecture for Web application. Components generally exchange
XML if used as part of the backend or middleware services and HTML if
used in the presentation layer.

The latter view is in our vision more attractive. Using HTTP and XML
over HTTP, the service is cleanly isolated using standard protocols
rather than proprietary communication. Running as a stand-alone
application, the attractive interactive development nature of Prolog can
be maintained much more easily than embedded in a C, C++, Java or C\#
application. Using HTTP, automatic testing of the Prolog components can
be done using any Web oriented test framework. HTTP allows Prolog to be
deployed in any part of the service architecture, including the
realisation of complete Web applications in one or more Prolog
processes.

When deploying Prolog in a Web application using HTTP, we must not only
implement the HTTP transfer protocol, but also support parsing,
representing and generating the important document types used on the
Web, especially HTML, XML and RDF. Note that, being widely used open
standards, supporting these document types is also valuable outside the
context of Web applications.

This paper gives an overview of the Web infrastructure we have
realised. Given the range of libraries and Prolog extensions that
facilitate Web applications we cannot describe them in detail. Details
on the library interfaces are in the manuals available from the
SWI-Prolog Web site.\fnurl{http://www.swi-prolog.org} Details on the
implementation are available in the source distribution. The aim of this
paper is to give an overview of the required infrastructure to use
Prolog for realizing Web applications where we concentrate on
scalability and performance. We describe our decisions for representing
Web documents in Prolog and outline the interfaces provided by our
libraries.

The benefits using Prolog for Web related tasks are illustrated using
three case studies: 1) SeRQL, an RDF query language for meta data
management, retrieval and reasoning; 2) XDIG, an eXtended Description
Logic interface, which provides ontology management and reasoning by
processing DIG XML documents and communicating to external DL reasoners;
and 3) A faceted browser on Semantic Web databases integrating meta-data
from multiple collections of art-works. This case study serves as a
complete Semantic Web application serving the end-user.

This paper is organized as follows. \Secref{markupdom} to
\secref{rdfdoc} describe reading, writing and representation of
Web related documents. \Secref{http} describes our HTTP client and
server libraries. \Secref{prologext} describes extensions to the Prolog
language that facilitate use in Web applications. \Secref{serql} to
\secref{facetb} describe the case studies.
