1. Trang chủ
  2. » Công Nghệ Thông Tin

Teach Yourself E-Commerce Programming with ASP in 21 Days phần 10 pdf

62 339 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 62
Dung lượng 248,27 KB

Nội dung

Answers for Day 19 Quiz 1. What is the difference between a hit, a page view and a unique user? For what is each useful? A hit is a browser’s request for a file from a Web server. A page view is the deliv- ery to the user of an entire Web page, including graphics elements. A unique user is a different person who visited a site within a specific period. Hits are the most useful measurement for estimating the technical requirements of a site, whereas page views and unique users are useful for marketing and strategic planning pur- poses. 2. What are the different log file formats that IIS 4.0 supports? Which ones are you likely to want to use? Why? IIS 4.0 can write log files in one of four different formats: NCSA Common Log File Format, ODBC Logging Format, Microsoft IIS Log File Format, or W3C Extended Log File Format. The most useful of these are ODBC Logging and W3C Extended Log File Format. ODBC Logging Format allows multiple Web sites to log information to the same database table, and allows you to report on Web site statistics in real-time. W3C Extended Log File Format allows you to record the most information, and allows you to save space by recording only the information that you are interested in. 3. Why is log file analysis an unreliable way to measure site traffic? Log files are an inexact way to measure site traffic because browsers, proxy servers, and firewalls tend to make traffic seem lower, whereas bots and Web spi- ders tend to make traffic seem higher. Still, log file analysis is more useful than not having any information at all. Answers for Day 20 Quiz 1. What is the difference between a client-side wallet and a server-side wallet? A client-side wallet is a relatively large piece of software that must be downloaded onto a computer. The software stores a customer’s credit card and other personal information in an encrypted file on that computer’s hard disk, and submits the information to electronic stores upon the customer’s request. 542 Appendix A 29 0672318989 app a 3/30/00 8:33 AM Page 542 Quiz Answers 543 A A server-side wallet has little or no software to be downloaded onto a computer. Instead, the wallet vendor provides a Web site where the customer can enter his information, which is then stored encrypted on the wallet vendor’s servers. The wallet vendor submits the customer’s information upon the customer’s request. 2. What is the difference between a SmartCard and a wallet? A SmartCard is a computer that is the size of a credit card, whereas a wallet is a piece of software. SmartCards can be used instead of (or in addition to) usernames and passwords to help secure client-side or server-side wallets. They can also run client-side wallets or “electronic purse” software. Electronic purse software enables consumers to download small amounts of electronic money directly into the SmartCard, and transfer the electronic money to merchants or other electronic purse users without involving a bank or other clearing company. 3. What is the ECML standard? The ECML standard is a defined set of names for the <INPUT> fields on an elec- tronic order form. It facilitates the compatibility of electronic wallets with E- Commerce sites. Answers for Day 21 Quiz 1. What is a “spider”? There is no central index to the Web. A spider is the part of a search engine that tries to finds as many Web sites as it can, by starting with a group of known Web pages and following all the links it can find. 2. What is a relevance metric? A relevance metric computes how well a particular page answers a query string. It takes into account the structure and contents of the page, sometimes including <TITLE>, <META name=”keywords”>, and <META name=”description”> tags. 3. What is a Web ring? A Web ring is an alternative to search engines and Web directories that makes browsing the Web on particular topics easier. A particular Web ring is an informal association of Web sites on a single topic that enables a surfer to navigate between all the sites in the ring. 29 0672318989 app a 3/30/00 8:33 AM Page 543 4. What is a link exchange? A link exchange enables Web site owners to cross-promote their sites with banner advertisements. For each banner ad the Web site owner displays, he gets a fraction- al credit toward displaying his own banner on another exchange member’s Web site. 544 Appendix A 29 0672318989 app a 3/30/00 8:33 AM Page 544 APPENDIX B Frequently Asked Questions About Active Server Pages This appendix addresses the questions that are most frequently posted on the Active Server Pages newsgroups and the ASPSite (the companion Web site to this book at www.aspsite.com). When appropriate, references are provided to specific chapters in this book where more information can be found. For updat- ed information, please visit http://www.aspsite.com/answers. Installation Questions Which Operating Systems Support Active Server Pages? Active Server Pages runs natively on Microsoft Windows NT Server 4.0, Microsoft Windows NT Workstation 4.0 with Peer Web Services, and Windows 95/98 with the Personal Web Server. 30 0672318989 app b 3/30/00 8:31 AM Page 545 Using Chili!Soft’s Chili!ASP (see http://www.chilisoft.com), you also can use Active Server Pages with SUN Solaris and IBM AIX. Chili!ASP enables Active Server Pages to run on Apache servers, Netscape Enterprise and FastTrack servers, the Lotus Domino Go Webserver, and O’Reilly Website Pro. How Do I Get the Latest Version of Internet Information Server and Active Server Pages? You can download the latest version of Active Server Pages and Internet Information Server at the Microsoft Web site. Go to http://www.microsoft.com/iis and select Downloads. Download the Windows NT Server 4.0 Option Pack. You will be provided with the option of downloading either the Windows NT or Windows 95/98 version of the Option Pack. How Do I Get the Latest Version of the ActiveX Data Objects (ADO)? The latest version of the ActiveX Data Objects (ADO) is available at the Microsoft Web site. Go to http://www.microsoft.com/data and download the Microsoft Data Access Components (MDAC). General Scripting Questions How Do I Add a Quotation Mark to a VBScript String? There are two ways to add a quotation mark to a VBScript string: myVar = “He said, “”Hello!”” “ myVar = “He said, “ & CHR( 34 ) & “Hello!” & CHR( 34 ) The first method uses two quotation marks in a row to create a single quotation mark. The second method uses the ASCII value of the quotation mark character. How Can I Break a Single VBScript Statement into Multiple Lines? You can break a single VBScript statement into multiple lines by using the _ underscore character. For example, the string in the following statement is broken into several lines of code by using the &_ character combination: myVar = “When in the Course of human events, “ &_ “it becomes necessary for one people to “ &_ “dissolve the political bands which have “ &_ 546 Appendix B 30 0672318989 app b 3/30/00 8:31 AM Page 546 Frequently Asked Questions About Active Server Pages 547 B “connected them with another, and to assume “ &_ “among the powers of the earth, the separate “ &_ “and equal station to which the Laws of “ &_ “Nature and of Nature’s God entitle them, “ &_ “a decent respect to the opinions of “ &_ “mankind requires that they should declare “ &_ “the causes which impel them to the separation. “ What Is the Proper Method of Comparing Strings in VBScript? When you compare two strings with the identity operator, the comparison is case sensi- tive. For example, the following statement returns the value false: <%= “apple” = “APPLE” %> There are two methods of performing a case-insensitive comparison of two strings: <%= StrComp( “apple”, “APPLE”, vbTextCompare )%> <%= UCASE( “apple” ) = UCASE( “APPLE” ) %> The first method uses the VBScript StrComp function with the vbTextCompare constant. The second method forces both strings into uppercase. You should be aware that several other VBScript string functions, such as the InStr and Replace functions, are also case sensitive. To perform case-insensitive comparisons with these functions, you must use the vbTextCompare constant. How Can I Re-enable Errors After Using ON ERROR RESUME NEXT ? The VBScript ON ERROR RESUME NEXT statement suppresses errors in your script. If you include the statement outside any functions or subroutines, the statement will apply to every statement that follows it (otherwise, it will apply only within the function or sub- routine). To re-enable the reporting of errors, use the ON ERROR GOTO 0 statement like this: <% ON ERROR RESUME NEXT ‘ The following error is ignored fakeOBJ.Blah ON ERROR GOTO 0 ‘ The following error is reported fakeOBJ2.Blah %> 30 0672318989 app b 3/30/00 8:31 AM Page 547 How Can I Prevent My Script from Timing Out? By default, an Active Server Page script will stop executing and time out after 90 sec- onds. If you have a long running script, the script may stop executing too early. You can extend the amount of time a script is allowed to run by using the ScriptTimeout proper- ty of the Server object. Here’s an example: <% Server.ScriptTimeout = 200 %> This statement changes the timeout period to 200 seconds. When Do I Need to Explicitly Convert a Variable to a Particular Data Type? If you are comparing numbers or dates and times and there is a danger that VBScript might interpret the values as strings, you should use one of the VBScript conversion functions. For example, suppose an HTML form contains two input boxes for two num- bers, and you execute the following script: <% firstNum = Request( “firstNum” ) secondNum = Request( “secondNum” ) %> <%=firstNum > secondNum %> If you enter 32 for the first number and 223 for the second number into the form, the script will output the wrong result. The script will return the value TRUE because the string 32 is greater than the string 223, even though the number is not. To force an inte- ger comparison, rather than a string comparison, use a script like this: <% firstNum = CInt( Request( “firstNum” ) ) secondNum = CInt( Request( “secondNum” ) ) %> <%=firstNum > secondNum %> The CInt function converts a value to the Integer subtype (also see the CDate, CCur, IsNumeric, and IsDate functions). When Should I Pass a Variable by Value and When by Reference? When you pass a variable by value to a subroutine or function, a new instance of the vari- able is created. Any changes made to the value of the variable do not affect the value of the original variable. On the other hand, when you pass a variable by reference, changes made to the variable do affect the value of the original variable. Here’s an example: 548 Appendix B 30 0672318989 app b 3/30/00 8:31 AM Page 548 Frequently Asked Questions About Active Server Pages 549 B <% SUB addOne( ByVal fvar, ByRef svar ) fvar = fvar + 1 svar = svar + 1 END SUB firstvar = 0 secondvar = 0 addOne firstvar, secondvar %> After this script is executed, the variable named firstvar has the value 0 and the vari- able named secondvar has the value 1. How Can I Add a Space Between the Output of Two Variables? For some mysterious reason, when you output two variables in a row in an Active Server Page, any spaces that appear between the variables will disappear. For example, the fol- lowing script outputs “AndrewJones” rather than “Andrew Jones”: <% fname = “Andrew” lname=”Jones” %> <%=fname%> <%=lname%> The easiest way to get around this problem is to use a script like the following: <% fname = “Andrew” lname=”Jones” %> <%=fname & “ “ & lname%> Does Active Server Pages Support Dynamic Includes? Some server-side scripting environments, such as Cold Fusion, support dynamic includes. A dynamic include enables you to use a variable for the name of the file to include in a page. Active Server Pages does not support dynamic includes. The following script will not work: <% myFile = “firstpage.asp” %> <! #INCLUDE FILE=”<%=myFile%>” > This include directive will attempt to include a file named “<%=myFile%>”, which proba- bly does not exist. The problem is that all server-side directives, including the #INCLUDE directive, are processed before Active Server Page scripts. If you must dynamically 30 0672318989 app b 3/30/00 8:31 AM Page 549 include different pages within an Active Server Page, consider using a script like the fol- lowing: <% myFile = “firstpage.asp” if myFile = “firstpage.asp” then %> <! #INCLUDE FILE=”firstpage.asp” > <% end if if myFile = “secondpage.asp” then %> <! #INCLUDE FILE=”secondpage.asp” > <% end if if myFile = “thirdpage.asp” then %> <! #INCLUDE FILE=”thirdpage.asp” > <% end if %> This script conditionally displays one of three different pages. The version of Active Server Pages bundled with IIS 5.0 will include better methods for dynamically including files. How Do I Use the Option Explicit Statement in an Active Server Page? The Option Explicit statement forces you to declare all your variables. Using this statement can make it easier to program complicated Active Server Pages because mis- spelled variable names will generate errors. You must use the Option Explicit statement before any other VBScript statement or HTML content in a script. If you don’t, you’ll receive an error like the following: Microsoft VBScript compilation error ‘800a0400’ Expected statement /test.asp, line 5 Option Explicit ^ Here’s an example that uses the Option Explicit statement correctly: <Option Explicit %> <html> <head><title>My Page</title></head> <body> <% 550 Appendix B 30 0672318989 app b 3/30/00 8:31 AM Page 550 Frequently Asked Questions About Active Server Pages 551 B DIM myVar myVar = “Hello!” %> </body> <html> Session and Application Variables Questions Why Do Session Variables Sometimes Fail to Work? Session variables depend on browser cookies. If a browser does not support cookies, or a user has turned off cookies or the user’s cookie file is corrupted, Session variables will not work. How Can I Remove an Application Variable? The current version of Active Server Pages, included with IIS 4.0, does not contain a method for removing Application variables. After you create one, it remains in memory until the Internet Service is stopped, the Global.asa file is changed, or the current appli- cation is unloaded. The version of Active Server Pages included with IIS 5.0, on the other hand, includes two new methods for removing Application variables: the Remove and RemoveAll methods. File Questions How Do I Detect Whether a File Exists? You can check whether a file exists by using the FileExists method of the FileSystemObject. The following script detects whether a file named test.txt exists: <% Set fs = Server.CreateObject( “Scripting.FileSystemObject” ) if fs.FileExists( “c:\test.txt” ) then Response.Write “File Exists!” else Response.Write “No File!” end if %> 30 0672318989 app b 3/30/00 8:31 AM Page 551 [...]... Advertising Review Unit), 342-343 catalogs administration See administration product catalog databases, 89 adding records to, 95 -100 connecting to, 93-95 creating, 89-90 manageproducts .asp page, 100 -102 , 113-117 Products table, 91-93 quotation marks, 102 -104 retrieving information from, 106 -108 updating, 104 -105 , 109 -112 upgrading to SQL Server, 90 categories of products, designing, 125-126 CatList .asp. .. connecting to, 93-95 creating, 89-90 manageproducts .asp page, 100 -102 , 113-117 Products table, 91-93 records, adding, 95 -100 retrieving information from, 106 -108 updating, 104 -105 , 109 -112 upgrading to SQL Server, 90 quotation marks, 102 -104 starting, 90 access control, Internet Service Manager, 379-384 Account page (order tracking), 260 account .asp page, 260-261 showorders .asp page, 262-263 showOrderStatus... updates, 200 adding records, 201-202 deleting records, 203-204 editing records, 202-203 Recordset object, 119 displaying records in, 119- 121 methods, 148-149, 201-203 opening, 121- 122 properties, 122-123, 134, 200-201 transactions, 218 -219 , 234 example of, 218 -219 marking end of, 218 stopping, 218 Advanced Server (Windows 2000), 11 advertising, 495-496 Ad Rotator component, 514-515 implementing, 516-517... 48 displaying, 52 persistent cookies, 49 reading, 49-52 session cookies, 48 storing, 49 support for, 50 cooperating with other e-businesses affiliate programs, 514 cooperative advertising, 510 link exchanges, 510- 512 Web rings definition of, 508 example of, 508- 510 cooperative advertising, 510- 512 CopyFile method, 81 copying text files, 81-82 customer interfaces cost of shipping, calculating iisCARTship... survey form, 84 form data, saving, 85-86 marketing form, 84 573 database access, 17 definition of, 13 files appending, 81 copying, 81-82 creating, 78-79 deleting, 82 including, 69-74 listing, 83-84 moving, 82 reading, 79-80 redirection, 75-76 verifying existance of, 83 writing to, 79 last page visited, retrieving, 41 limitations of, 18 objects See names of specific objects operating system compatability,... processCards .asp page, 250-252 processCards2 .asp page, 252-253 Socket component, 245 B banks (CyberCash), 241 banner ads, 510 link exchanges, 510- 512 purchasing, 513 base64 text, decoding, 290 Decode method, 291-292 UUEncoding, 290-291 basic authentication (HTTP), 274, 288 batches of email See bulk mailings BBBOnline privacy program, 341 beginning ADO (ActiveX Data Object) transactions, 218 BeginTrans method, 218 ... 185-186 Certificate Signing Requests (CSRs), 185-186 575 certificates (server certificates) applying for, 186-187 installing, 187 Certification Authorities, 336-337 changing See editing charge cards See credit card transactions CheckError method, 367368 checkout pages (shopping cart), 213 address/payment information retrieving, 220- 221 updating, 221- 224 customer items, transferring to Orders table, 224-226... targeting, 513 affiliate programs, 514 banner ads, 510 link exchanges, 510- 512 purchasing, 513 bulk mailings, 428 marketing, 438 message composition, 432-435 recipients, 429-432 sending messages, 435-437 Children’s Advertising Review Unit, 342-343 favorite product categories (customized ads), 307 default .asp page modifications, 315-316 displaying featured products, 313-315 retrieving, 310- 311 saving,... 391-395 storeFuncs .asp, 393 updateProduct .asp, 398-401 upload .asp, 393-394 FTP (File Transport Protocol) Service, 385 anonymous access, 386 configuring, 386-387 CuteFTP, 389 file uploads, 387-389 installing, 385-386 Internet Service Manager (HTML), 377-378 access restrictions, 379-384 installing, 378-379 remote administration tasks, 384 Administrator accounts, 331-332 adminPage .asp page, 405-406 ADO... ORDER BY pub_name • Using SELECT to retrieve the names of the first 10 authors from the Authors table in order of the last name SELECT TOP 10 au_fname, au_lname FROM Authors ORDER BY au_lname INSERT INSERT table_name ( column_list ) VALUES ( value_list ) The INSERT statement is used to insert one or more rows into a database table (Microsoft Access uses INSERT INTO) Examples • Using INSERT to add a new . break a single VBScript statement into multiple lines by using the _ underscore character. For example, the string in the following statement is broken into several lines of code by using the. central index to the Web. A spider is the part of a search engine that tries to finds as many Web sites as it can, by starting with a group of known Web pages and following all the links it can find. 2 AM Page 553 Before entering a string into a database table with the Connection object, you must first translate any single quotes into two quotes in a row. The following script avoids errors caused

Ngày đăng: 13/08/2014, 08:21

TỪ KHÓA LIÊN QUAN