It shows a-typical Web page that prompts the user to enter information, which will be used later to extract information from a database on the server. The site shown is Info seek, a widely used search engine on the Web. The search argument is “VB +books” (search for documents about “·VB” that also contain the word “books”) .
When the Search button is clicked, the client sends the following URL to the server:
Titles is the name of an application on the server that will search the database and supply the results. It’s not an ASP application. but it doesn’t make any difference. The same arguments would be supplied if it were an ASP application. the same document would be returned to the client. The client must transmit the name of the application that will process the parameter values on the server; that’s all the client needs to know. This piece of information is supplied in the <FORM> tag of the document.
Start Internet Explorer, connect to the ~ site, and submit some search arguments ..When the server returns the requested information, you’ll see the name of the application that retrieved the data on the server along with the arguments (a string to the one shown above) in the Address Box of the browser.
The information entered by ,the viewer on the Form is transmitted to the server in the form of parameter values, following the URL of the application that will process them. Parameters have a name and a value and they appear as:
When you’re using a Form to collect data from the visitor, the name of the parameter is the name of a control on the Form, and the value is the control’s value. Multiple of parameters are separated by an ampersand character (&), as shown here:
LastName Pet:rOutsosIFirstNa = Evangelos
The string with the parameters is appended to the URL by placing a question madt-(7) after the name of the application that will process it on the server (the name of the ASP file). If the value of a control con~ spaces, each space is replaced by a plus sign (+), as in the following example:
The parameters follow the question made, which appears at the end of the URL. In the example of the Info seek site, the first parameter is qt (which, most likely, stands for query text), and its value is the string “VB + books”. The space. was replaced by a plus sign, and the plus sign in the original search argument was substituted with %2B (2B is the hexadecimal representation of the plus sign’s ASCII value). The parameter information tells the application of the server to generate an document without frames, and the param.r st=10 specifies that it shot¥ display the second batch of 10 matching titles. As you can see, the search recalled nearly 80,000 , But they can be displayed on the client 10 at a time. Each time you click the Next 10 hyper Link. the value of sf is increased by 10 (and each time you click the Previous 10 hyperlink, the value of the parameter st is decreased by 10). This is all the information needed by the titles application on the server to display the appropriate me with the results of the search.
:the Web server can’t decipher requested URL, but it does have the intelligence to invoke the program whose name appears in the URL string and pass to it the parameter following the program’s name. Traditionally, the programs that process client requests in real time on the server are called scripts, and most of them were written in Perl.
Building Parameter Strings
You can use two methods to build URLs that call special applications on the and supply additional information to them:
• The simple method is to supply all the required information in the <FORM> tag and let the.browser contact the server and submit the values of all the controls on the Form.
• The second method is to build the parameter string with VBScript commands and submit it to the server. with the Navigate method of the Window object.
Starting with the simple method, let’s review the FORM.HTM page we looked at.The Form section on the page, which is shown, was inserted with the following tag:
The Action attribute specifies the URL of the application to be invoked. The application is an ASP file that resides in the ASP pages virtual folder of the same Web site, which’ uploaded the current page:’The METHOD attribute specifies one of the two .method for submitting data from the client to the server. For the examples in this ,we are going to use the GET method.
The Form section of the FORM.page shown contains the Controls and values listed in Table.
When the Submit button at the bottom of the Form is clicked, the client transmits the following string to the server. The browser automatically builds this string (no· script is needed in this page).
The second way to submit the parameter to the server is to build the parameter string with VB Script commands and submit it to the server with the Navigate method of the Window object. Here’s how you can contact an application on the server from within a script (when the user clicks a regular Command button, ‘for example):
The URL String variable is a single long line, but it had to be broken somewhere to fit on the printed page. You would normally build this string in pieces, using the concatenation operator. You should use the first method, which is much simpler, except for unusual situations in which the information to be transmitted can’t be entered in controls.
Contacting a Server Application
At this point, you probably want to test the information presented so far and see for yourself how the client interacts with the server. This process requires that your pages are processed by a server. You can open the FORM.HTM page by double clicking its icon, but unless you have a Web server running on your network, you won’t be able to see what happens on the server’s side. The page won’t submit any information to them, because the page wasn’t downloaded from a server.
If you are using the Internet Information Server, you’re probably on a local area network, and you can get some help from your network administrator. For the benefit of those who want to experiment with a Web server on a stand-alone computer, I will show you how to configure the Personal Web Server and use it to test the examples in this chapter. The Personal Web Server is a light version of the Internet Information Server, which runs under Windows 95/98 and can be used to service as many as 10 clients simultaneously.For u\e purposes of this book, the Personal Web Server is quit,e adequate, and you can-use it to build functional Web sites that interact with clients through server-side scripts. When the site has been developed and tested, you can post it on a machine running statement Information Server,
The Personal Web Server comes with Visual Studio 6 and Visual Basic, To install it, you must install the optional package Windows NT Option Pack. Installing the PWS is a totally automatic process. After its installation, the PWS starts automatically whenever you turn on the computer.
.Notice that the new virtual folder ‘has its Script option checked. This means you can store scripts in it. The folder where the server scripts are stored must have its Scripts option checked; if this option is not checked, the Web server will refuse to execute the scripts in this folder. (If a virtual folder isn’t supposed to contain scripts, clear the Scripts option for this folder as a security measure.)
Connecting to Your Web Server
To connect to your own server, start Internet Explorer and enter the following address in the browser’s Address box
This is the address of the local computer and is the same on every machine. It’s a reserved IP address that connects you to the server running on the same machine from which the request is made: Entering this address (or simply 127.0.0.1) in the browser’s Address box displays the Web server’s default document. You can copy in the server’s root folder any HTML document and open it by specifying its name along with your server’s address. Even better, create a virtual folder under the C: lNETPUB\ WWW.Root folder ( it MVB6), and place the HTML files you want to test there. The following address will open the Calendar.hbI\ file in the browser’s window:
In the following section, you’ll see how to develop application that run on the server arid can be invoked from the client. These applications are quite simple to develop (probably simpler than you think).They are scripts, just like the scripts you can embed in HI’ML pages, only they run on the server. ‘They are called Active Server Pages, and as a VB programmer, you can start server side scripts immediately.
Visual Basic 6 provides a special type of project, the Application type, that automates the process of building Active Server Pages to run on Internet Information Server. Even with the automated tools provided by this application type, you can’t go far without a basic understanding of server-side scripts and the provided by ASP for interacting with the client.