Web Servers

team lib

To use Active Server Pages (ASP) files you need a Web server that supports ASP. For most people using modern Microsoft Windows Operating Systems, this will be Microsoft Internet Information Server (IIS).

You might be wondering why we are talking about a web server, as Internet Explorer can open Web files directly from the Windows Explorer. The trouble is that ASP files don't work if opened this way. Why is that? Well, a standard HTML file just contains text and HTML tags to tell the browser what the text should look like. There's an important point there - the HTML is interpreted by the browser. So the browser needs nothing else to be able to display a standard HTML page.

An ASP file however, is different, because not only does it contain HTML, it also contains scripting code. This is code, much like VBA, that is run by the Web server, before the ASP file is sent to the browser. In the case of the ASP pages shown in Chapter 18, here's what happens:

  1. The user requests the ASP page.

  2. The Web server finds the page and looks at the script in it. ASP script is contained within angle brackets as < % % > anything within with the script tags is sent to the ASP engine where it is executed.

  3. The script connects to the database and extracts the data.

  4. The script then formats the data into HTML.

  5. The Web server sends the HTML back to the user.

So the user only receives HTML, but to get that HTML the page has to be processed by a Web server. That's why we just can't open an ASP page directly in the browser - it has to go via the Web server.

IIS

IIS is provided with Microsoft Windows 2000 and Windows XP Professional. It's not installed by default, but contains a simple installation program. You can install IIS from your computer's Control Panel , under the Add/Remove Programs option:

IIS is a very capable web server, but one thing you must do when using this product is to make sure you keep all security patches up-to-date. Microsoft's web servers remain a top target for web hackers, so on live systems, you should always be aware of security.

click to expand

Creating Virtual Directories with IIS5

  1. You can create a virtual directory from the Internet Information Services icon in Administrative Tools . This open the IIS Management Console:

    click to expand
  2. Select the Default Web Site

  3. Right-click and select New Virtual Directory from the context menu:

    click to expand

    This opens the Virtual Directory Creation Wizard which will take you through the process of creating a virtual directory.

  4. In the first Wizard Screen simply click Next

  5. Enter an Alias for the new directory (the name you'd like to use in its URL). For our examples we've chosen BegVBA :

    click to expand
  6. Click Next . Then enter the path (or use the browser button) to indicate the physical location of your database:

    click to expand

    Click Next . The following screen allows you to set permissions for access to the virtual directory:

    click to expand
  7. We don't need to anything special for our example, so just accept the defaults and click Next to finish the set up

  8. That's it. You have set up your first virtual directory using Windows XP Professional.

A Note on Browsing

On the permissions screen you may have noticed the option Browse . Browsing - if no explicit document is requested , and there is no default document in the directory, then a listing of the directory is returned, much like a listing of files in Windows Explorer.

Directory browsing is extremely useful when testing as it allows you to quickly select files in the browser without having to explicitly type them in the URL. However, you should be wary of using directory browsing on live machines as it gives a complete list of every file in the virtual directory.

Localhost

Most URL's you see start with www , but if you are using your own machine you might not have a www address set up. To get around this problem you can contact your local machine by the following:

 http://localhost 

This replaces the root part of the URL, and you can then add your virtual directories onto the end of this (you add the name of the virtual directory, not the name of the folder that you created it from):

 http://localhost/BegVBA 

If you've got directory browsing enabled, and there's no default document, then this will show you a directory listing. Or, you can specify a document:

 http://localhost/BegVBA/tblIceCream.asp 

This tells the web server to fetch the specified ASP file.

Note 

If you experience any difficulties setting up your DSN, or getting your Virtual Directories to work, remember that you can get assistance from support@wrox.com

 
team lib


Beginning Access 2002 VBA
Beginning Access 2002 VBA (Programmer to Programmer)
ISBN: 0764544020
EAN: 2147483647
Year: 2003
Pages: 256

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net