Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
16
More specifically, the ADO object model provides obijects and collections (i.e containers that hold one
or more objects of a specific type) as follows:
Object/Collection Description
Recordset object This object allow us to work (read, modify, collect) with the data
Error object This object represents an crror generated by the data souree.
Command object This object provides another way to create a Recordset object.
Methods Description
Move Next This method helps us to move to the next record set.
Move Previous This method helps us to go back to the previous record on the
Recordset.
Move First This method helps us to the first record in the recordset.
Move last This method helps us to the last record in the recordset.
BOF It is a Boolcan value that is True when you are still at the
EOF It is a Boolcan value that is True when you reach the end of the
Recordset.
As Recordset object contains several set of record, we can access only one record at a time by using
above methods. The Recordset object maintains a pointer to the current record and we can move that
pointer forward or backward.
Of
5.17
Program : AccessDb.asp
<%@LANGUAGE = VBScript%>
<html!>
<body>
<%
Dim objRS
objRS.Move Next
Loop
objRS.Close
objConn.Close
%>
</body>
</html>
In the above program, the following line includes the file that establishes the connection to the
Database:
<%
Dim objConn
objConn.Open
%.
The first and second lines in the above code creates the connection object which holds the
The third line in the above code scts the connection string which tells the connection object
about using a system DSN. A system DSN the (Data Source Name) is a file that contains information
about the database such as where it is and what Kind of database it is.
5.18
CGI programming is all about creating and using CGI scripts. In PERL
programming , a CGI script is only a PERL program in a file with the
extension egi. The CGI script are placed on ISP (Internet service provider)
web servers and these scripts will create web pages dynamically using PERL
code (applications ) responding to user requests.
Figure 5.6 illustrates the interaction between client and server when the client
requests a CGI script CGI script process information like credit-card number
recived from a Form by verifying or rejected. Web server (usually Web –master
or the author of websites) executes CGI scripts (programs) upon client ‘s request
. These programs are saved with a certain filename and extension (Such as. Cgi
or .pt) within a special directory (such as cgi-bin) on web servers or any other
computer. Thus, after the application output is sent to the web server through
CGI , the result are sent to the client,
CGI Script are used in form processing and presenting Business Logic.
HTML froms are used to collect data from users and sent it to a web server for
validation processing by server-side program and scripts. This allows users to
register and purchase software products, credit-card validation etc. So. A
registration from could be used , by a software company to obtain profile
information of the user before allowing him to download software.
The following program generates an HTML from to collect data from user and
send it to web server for validation (Business Logic) by CGI Script:
<html>
<head>
<title>
</title>
</head>
<body>
5.20
</form>
</body>
</html>
In the above [program , the <frorm> tag generates an HTML from , and when the user clicks register
button , the from information is to the server . The statement action = “/cgi-bin/Handle Form Data. Cgi”
directs the server to exeoute the HandleFrom Data cgi. CGI script located in cgi –bin directory to process
(validate) the posted from data, we have assigned unique names like fname , Iname , email creadit to
each of the CGI script Handle Handle FromData. Cgi which can then access the submitted value for
specific filed . The following CGI script (program) processes the data posted by previous HTML program
RegistrationFrom.html and sends a Web page response back to client .
# ! /usr/bin/peer!
Print (H1”);
Else
5.21
Print
(</body> </html>);
In the above program , the use statement instructs PERL pfograms to include functions (modules ) of
predefined [packages. The CGI module, contains usful function for CGI scripting in PERL, include
functions that return strings representing HTML tags.With the use statement , we can specify the import
tag : standard to import a predefined set of standard functions .
Function param is part of the PERL (CGI) module and retriever value from a Form ‘s Input Fields.
We access the value entered by te user in the Form’s Textfieds (whose names are fname , Iname , email
and creadit ) by caling param (‘”fname “) , param (“Iname “) . param (“email”) and param (creadit “) and
keep the values returned in variables $ fname , $Iname , $email and $cridit of CGI script .
Remember , while creating dynamic web pages in PERL, we output HTML by using print statement The
print statement display s the result on the clint’s Web browser.
Next, we deletemine Whether the credit –card number entered by the clint is valid, The design of
verifying information is called as Bussiness Logie. This verification is done by if conditional statement The
expression “j\d(3) “, then it mathes the closing parenthesis by”\)” then three digits by “\[3] “. Then a
hyphen by – and at last it matches four digits by “\d[4] “, Also , we used 1 and $ metalcharacters to
confirm that there are no extra are characters at the beginning or end of the string .
Now , if the credit – card number is valid , then a web page is sent if part executinon , Thanking the
client completing registration from . But if the creadit-card number is invalid, the else part gets
executed, instructing the user to enter a valid creadit- card number.
Dynamic Web pages greatly improves the look and feel of a web site. Dynmic web pages eincludes the
current date or time , rotating banners or advertise or advertisements, special offers or daily news
(newspaper) since they are all current informations. Clients receive new information on every visit and
thus they revisit the web site in the future . Thus. These dynamic web pages are generated mostely by
using SSI (Server – Side Includes, ).
Server – side Includes (SSi) are the commands embedded in a HTML documents to create dynmic
contents on web page. SSI commands (like ECHO and INCLUDE) creates the dynamic contents (like the
current time , web page hit counter i.e ., counting number of times a client requested the web page or
information that is stored in a database ) on a web pag. The SSi command EXEC ean ber used to run CGI
scripts and enmbed their output directly on a web page. A document containing SSi commands has
shtml extension (where s stands for server ). nThe shtml files are parsed by the server and it excutes the
commands and writes the output to client . it is advviable for the minimum use of server include
commands, as they decreases the performance of the the server.
Since all web does not . support SSI commands. They all are written as HTML comments.
5.22
XML is a markup language developed by world wide web Consrtium’s (W3C’s ) XML working group in
1996. XML documents contains only data but not formatting instruction . XML, permits us to creat
markup for any type of information. That is in, XML , we create our own tags and syntax for those tags.
This extensibility enables us to create own new markup languages for mathematical formulas, music,
etc. Some XML-based markup language Intertion Language (for multimedia presentations , ).CML –
Chemical Markup Language (for Chemistry ) and XBRL – eXtensible Business Reporting Language (for
financial data exchange.)
XML document is highly portable. Processing XLM document requires a software called as XML parser or
XLM procer checks the XLM document’s syntax and process marked-up data. XML parsers can support
Document object Model (DOM) or simple AOL for XML (SAX). DOM-based parserts builds tree structure
containing XLM documents for tags, text, comments, etc. Even Internet Explorer 5.5. (IE 5.5) parser
(msxml) can parse and display XLM document.
From Microsoft’s point of view, we can use XML to create the following :
An ordinary document.
A structure record. (For example : An appointment record or purchase recode).
An object with data and methods . (For example: The persistent from of a Java object or ActiveX
control).
A data recod (For example : The resultset of a query)
Metacountent about a web site. (For example. Channel Definition Format (CDF)).
Graphical presention. (For example : An application’s user interface)
XML schemens and types.
A XML document ends with the. Xml filename extension. Viewing or b modifying an XML document
does not requires special software . Any editor that supports ASCII/Unicode charecters can open
XML documents to view and editor. An important feature of XML is that it is that is both human
readable and machine readable.
The following code is our first XML document that holds the purchasing records of several
customers;
<purchase>
<title>
</title>
<date>
</date>
<custmore>
<name>
</name>
<onter>
<item>
</item>
<order>
</customer>
<customer>
<name>
</name>
<order>
<item>
<price>$ 1.50</price>
</item>
<item>
</item>
</order>
</customer>
</purchase>
You might wonder that, XML provides you with a way of creating and structuring your data in a
manner that first that data.
XML document begins with XML processing instruction <?xml version = “1.0”>, which helps
Internet Explorer to know that this document is XML. Much like the <HTML> tag indicates an HTML
document. Placing space characters before XML declaration is an error.
Every XML document must contain exactly one root element which contains eery other XML
element In above program, purchase is the root element .
XML Element title, data contains text tht describes the purchase ‘s title, date of the document,
respectively . The other elements such as customer, name, order, item that contains other elements
are called as XML contains, Elements. Elements inside i.e. a container element first_name,
Last_name, product and price are called as child elements or children of that container elements .
XML elements and attributes names within XML elements can be of any length and may container
letters digits, underscore, hyphens and periods. However . XML element names must beging with
either a letter or an underscore Using either a space or a tab in an XML elements name or attributes
name is an error. XML element name and attributes names should be meaningful and in human
readable format , For example, use <purchase> instead of <pur>.
IE 5.5 places the symbols plus sign(+) and minus sign (-) to container elements in the output of the
above XML document. A minus sign display container elements child elements .Clicking tha minus
sign, hides container elements chikern and replaces the minus sign with a plus sign. Clicking the plus
sign again displays continer elements children the plus sign with a minus sign
XML document allows authors to create their own XML elements with their own names. But this can
result in naming collisions i.e., multiple different element can have the same in one XML document.
For example ,
And
<subject> Multimedia and Web Design </Subject> uses XML element subject to markup a piece of
data . However , in the first case the subject is something oe studies in school , whereas in the
second case the subject is in the filed of engineering .
But XML, Namespaces provide a means fr us to prevent collisions by differentiating these two
subject elements using nams=espaces prefixes;
And
<engineering ; subject> Multimedia and Web Design </engineering ; subject>
XML namespace uses the keyword xmlns to create namespace prefixes and assign the
corresponding URI (Uniform Resource Identifier ) that uniquely identifies the name space . A URI is a
series of characters for differentiating names, for examples, the string
“Surepublication: textInfo” could be a URI for a namespace that contains elements and attributes
related to SURE publications.
The following program demonstrates namespace the differentiate two didtinct files;
Program : namespace.xml
<directory
<text: description>
</text : file>
</image : file>
</directory>
In the above program , to get the file and description of the text of the book, we have prefixed with
the namespace text so, b it searches it in sure publications: book: text Info . And to get the file and
description of the image (logo) of the book , we prefixed with the namespace image. So , it searches
it in Sure publications book: image Info .
An XML document is called as Valid XML document if there is a Document Type Definition (DTD ) OR
XML Schema associated with it and if the document complies with the DTD or XML schema.
An XML document is called as Well-Formed XML document if it contains one or more elements, and
if there is precisely one element (the root or document element) for which nethier the start tag the
end tag is inside any other element, and if all other tags nest within each other correctly , and if all
elements used the document must either be predefined in XML. DTD or XML schema.
As ML documents can have many different structure , an application cannot tell whether particular
XML document is completer or missing data or order properly. So, this problem can be solved by
providing an extensible means of specifying XML document structure using the following two types
of documents;
Applications can use DTDs or schemas to perform validity checks on XML documents.
The DTD indicates the syntax of the XML elements for example, what elementrrs can be inside other
elements. The DTD follows the WBC syntax conventions, which means each element is specified
with <! ELEMENT>and the contents of an element are specified with # PDCDATA (Parsed Character
Data. ).
If we want to sure that our documents are valid (i.e, adhere to the syntax rules we set). Then we
need Document Type Definiton (DTD) or a schem. We can use the following two types of DTDs with
XML documents:
In an internal DTD, we enclose the DTD in a <!DOCTYPE> element, providing the name of the root
element of the document (which is PURCHASE here in this program ) in the <! DOCTYPE> element .