Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

Link:http://output.to/sideway/default.asp?qno=130200006

ASP Server Component, Pre-made Function, Content Linking component

ASP Server Components

Some of the ASP server components are the common features found in dynamic web pages. These base ASP server components are provided to enrich the pre-made functions of ASP technology for making dynamic and interactive web pages. However, some IIS pre-made components are not installed for all version of IIS. Ad Rotator, Browser Capabilities, Content Linker, Content Rotator, Counters, Logging Utility, My Info, Page Counter, Status, and tools are not installed with IIS 6.0. However, if you upgrade your Web server from a previous version of IIS, the pre-made components are not removed. Some IIS pre-made components, ASP content rotator and nextlink,  are deprecated in IIS7. And most IIS pre-made components are either not installed with IIS7 or their usage is not supported.

Content Linking component

The Content Linking component can be used to create a Nextlink object that acts as a page indicatior in an ASP page for controlling the ASP page navigation in a collection of ASP pages. The function of the Nextlink object is to automate the generating and updating the tables of contents and navigational links to previous and subsequent web pages according to a Content Linking List file. The Content Linking List file contains the list of the family of linked web pages. The Content Linking List file is stored on the web server and is used by the Nextlink object as the reference. Therefore a Nextlink object is suitable for an online newspapers or forum message listings etc. 

File Name

The file name of the Content Linking component is Nextlink.dll.

Syntax

Set NextLinkName = Server.CreateObject( "MSWC.NextLink" )

Parameters

NextLinkName

The parameter "NextLinkName" is the name assigned to the instance of the Nextlink object created by the call using the Server.CreateObject.

Remark

The Content Linking component does not work with Internet Information Server 7 (IIS7).

NextLink.GetListCount Method

NextLink.GetListCount method is used to count and retrieve the total number of web pages listed in the Content Linking List file.

Syntax

NextLinkName.GetListCount( listURL )

Parameters

NextLinkName

The parameter "NextLinkName" is the name of the instance of the Nextlink object to be set.

listURL

The parameter "listURL" is used to specify the location of the Content Linking List file.

Return Values

The NextLink.GetListCount method returns an integer of the total number of items linked in the Content Linking List file.

NextLink.GetListIndex Method

NextLink.GetListIndex method is used to retrieve the index number of the current web page in the Content Linking List file.

Syntax Syntax

NextLinkName.GetListIndex( listURL )

Parameters

NextLinkName

The parameter "NextLinkName" is the name of the instance of the Nextlink object to be set.

listURL

The parameter "listURL" is used to specify the location of the Content Linking List file.

Return Values

The NextLink.GetListIndex method returns an integer of an index number specifying the position of the current item linked in the Content Linking List file. The index number of the first item linked in the Content Linking List file is 1 and the NextLink.GetListIndex method returns 0 if the current page is not linked in the Content Linking List file.

NextLink.GetNextDescription Method

NextLink.GetNextDescription method is used to retrieve the text description of the next web page in the Content Linking List file.

Syntax Syntax

NextLinkName.GetNextDescription method( listURL )

Parameters

NextLinkName

The parameter "NextLinkName" is the name of the instance of the Nextlink object to be set.

listURL

The parameter "listURL" is used to specify the location of the Content Linking List file.

Return Values

The NextLink.GetNextDescription method returns an ASCII string of the description of the next item linked in the Content Linking List file. If the current page is not linked in the Content Linking List file, the NextLink.GetNextDescription method returns the desctription of the last item on the Content Linking List.

NextLink.GetNextURL Method

NextLink.GetNextURL method is used to retrieve the URL of the next web page in the Content Linking List file.

Syntax Syntax

NextLinkName.GetNextURL method( listURL )

Parameters

NextLinkName

The parameter "NextLinkName" is the name of the instance of the Nextlink object to be set.

listURL

The parameter "listURL" is used to specify the location of the Content Linking List file.

Return Values

The NextLink.GetNextURL method returns the URL of the next item linked in the Content Linking List file. If the current page is not linked in the Content Linking List file, the NextLink.GetNextURL method returns the URL of the last item on the Content Linking List.

NextLink.GetNthDescription Method

NextLink.GetNthDescription method is used to retrieve the text description of the index Nth item in the Content Linking List file.

Syntax Syntax

NextLinkName.GetNthDescription method( listURL,i )

Parameters

NextLinkName

The parameter "NextLinkName" is the name of the instance of the Nextlink object to be set.

listURL

The parameter "listURL" is used to specify the location of the Content Linking List file.

i

The parameter "i" is used to specify the index number of an item in the Content Linking List file.

Return Values

The NextLink.GetNthDescription method returns an ASCII string of the description of the index Nth item linked in the Content Linking List file.

NextLink.GetNthURL Method

NextLink.GetNextURL method is used to retrieve the URL of the index Nth item in the Content Linking List file.

Syntax Syntax

NextLinkName.GetNthURL method( listURL,i )

Parameters

NextLinkName

The parameter "NextLinkName" is the name of the instance of the Nextlink object to be set.

listURL

The parameter "listURL" is used to specify the location of the Content Linking List file.

i

The parameter "i" is used to specify the index number of an item in the Content Linking List file.

Return Values

The NextLink.GetNthURL method returns the URL of the index Nth item linked in the Content Linking List file.

NextLink.GetPreviousDescription Method

NextLink.GetPreviousDescription method is used to retrieve the text description of the previous web page in the Content Linking List file.

Syntax Syntax

NextLinkName.GetPreviousDescription method( listURL )

Parameters

NextLinkName

The parameter "NextLinkName" is the name of the instance of the Nextlink object to be set.

listURL

The parameter "listURL" is used to specify the location of the Content Linking List file.

Return Values

The NextLink.GetPreviousDescription method returns an ASCII string of the description of the previous item linked in the Content Linking List file. If the current page is not linked in the Content Linking List file, the NextLink.GetPreviousDescription method returns the desctription of the last item on the Content Linking List.

NextLink.GetPreviousURL Method

NextLink.GetPreviousURL method is used to retrieve the URL of the next web page in the Content Linking List file.

Syntax

NextLinkName.GetPreviousURL method( listURL )

Parameters

NextLinkName

The parameter "NextLinkName" is the name of the instance of the Nextlink object to be set.

listURL

The parameter "listURL" is used to specify the location of the Content Linking List file.

Return Values

The NextLink.GetPreviousURL method returns the URL of the Previous item linked in the Content Linking List file. If the current page is not linked in the Content Linking List file, the NextLink.GetPreviousURL method returns the URL of the last item on the Content Linking List.

Content Linking List File

The Content Linking List File is used to store the ordered entries of linked web pages in a collection for the Content Linking component. Each linked web page details is stored on one single line in the list. Each line should end with a carriage return and each detailed item on a line must be separated by a TAB character.

The Content Linking List File should be stored under the web server directory so that the Content Linking List File can be accessed through a virtual path. Besides the URL of the linked web page, text description and comments are allowed as optional detailed items for each item entry placed after the URL of the linked web page and separated by a TAB character.

The change in a Content Linking List File may need to restart the IIS services in ordered to make the changes become effective.

Syntax

(Web-page-URL [ text-description [ comment]])+

Parameters

[...]

The parameter "[" & "]" is the indicator of the bracketed parameters by a pair of square brackets "[...]" is an optional item unless other specified.

(...)+

The parameter "+" is the indicator of the bracketed property parameters by a pair of brackets "(...)" can be repeated one or more times.

Web-page-URL

The parameter "Web-page-URL" is used to specify the virtual or elative URL of the linked web page. The URL path only supports the format of "filename" or "directory\filename" and absolute URLs starting with "http:", "//" or "\\" are not supported and will not be processed by the methods such as GetNextURL and GetListIndex. The list of the content path should be checked to ensure there is no collisions or infinite loops can occur.

text-description

The optional parameter "text-description" is used to specify the description of the Web-page-URL. And the text-description should be separated by a TAB character with the  Web-page-URL.

comment

The optional parameter "comment" is used to specify the detailed description of the Web-page-URL. And the text of comment is not processed by the Nextlink object and should be separated by a TAB character with the text-description.

Examples

  • Example of making use of Nextlink object to display the list of the current browser in a table.

    ASP Page, Nextlink.asp:

    <%
    Set NextLink = Server.CreateObject("MSWC.NextLink")
    ListFile = "nextlinklist.txt"
    count = NextLink.GetListCount(ListFile)
    I = 1
    %>
    The total number of the linked pages in the list is
          <%=NextLink.GetListCount(ListFile)%><br />
    The list of the linked pages:<br />
    <OL>
    <% Do While (I <= count) %>
    <LI>
    <%=NextLink.GetNthURL(ListFile, I)%>:    
    <%= NextLink.GetNthDescription(ListFile, I) %>
    </LI>
    <% I = (I + 1) %>
    <% Loop %>
    </OL>
    <BR>
    The index of the current page is
            <%= NextLink.GetListIndex(ListFile)%><br />
    The previous page is <%= NextLink.GetPreviousURL(ListFile)%><br />
    <%= NextLink.GetPreviousDescription(ListFile)%><br />
    The next page is <%= NextLink.GetNextURL(ListFile)%><br />
    <%= NextLink.GetNextDescription(ListFile)%><br />
    The 5 page is <%= NextLink.GetNthURL(ListFile,5)%><br />
    <%= NextLink.GetNthDescription(ListFile,5)%><br />

    HTML web page ouput:
    The total number of the linked pages in the list is 8
    The list of the linked pages:
    1. Ex_GetListCount.asp(GetListCount Method Ex.)
    2. Ex_GetListIndex.asp(GetListIndex Method Ex.)
    3. Ex_GetNextDescription.asp:-GetNextDescription Method Ex.)
    4. Ex_GetNextURL.asp(GetNextURL Method Ex.)
    5. Ex_GetNthDescription.asp(GetNthDescription Method Ex.)
    6. Ex_GetNthURL.asp(GetNthURL Method Ex.)
    7. Ex_GetPreviousDescription.asp(GetPreviousDescription Method Ex.)
    8. Ex_GetPreviousURL.asp(GetPreviousURL Method Ex.)

    The index of the current page is 0
    The previous page is Ex_GetListCount.asp
    GetListCount Method Ex.
    The next page is Ex_GetPreviousURL.asp
    GetPreviousURL Method Ex.
    The 5 page is Ex_GetNthDescription.asp
    GetNthDescription Method Ex.
  • Example of Content Linking List File with list of the Nextlink Method Examples

    Text in the Content Linking List File, NextLinkList.txt:

    Ex_GetListCount.asp   GetListCount Method Ex.   First Page
    Ex_GetListIndex.asp   GetListIndex Method Ex.
    Ex_GetNextDescription.asp   GetNextDescription Method Ex.
    Ex_GetNextURL.asp   GetNextURL Method Ex.
    Ex_GetNthDescription.asp   GetNthDescription Method Ex.
    Ex_GetNthURL.asp   GetNthURL Method Ex.
    Ex_GetPreviousDescription.asp   GetPreviousDescription Method Ex. .
    Ex_GetPreviousURL.asp   GetPreviousURL Method Ex.

Link:http://output.to/sideway/default.asp?qno=130200005

ASP Server Component, Pre-made Function, Browser Capabilities Component

ASP Server Components

Some of the ASP server components are the common features found in dynamic web pages. These base ASP server components are provided to enrich the pre-made functions of ASP technology for making dynamic and interactive web pages. However, some IIS pre-made components are not installed for all version of IIS. Ad Rotator, Browser Capabilities, Content Linker, Content Rotator, Counters, Logging Utility, My Info, Page Counter, Status, and tools are not installed with IIS 6.0. However, if you upgrade your Web server from a previous version of IIS, the pre-made components are not removed. Some IIS pre-made components, ASP content rotator and nextlink,  are deprecated in IIS7. And most IIS pre-made components are either not installed with IIS7 or their usage is not supported.

Browser Capabilities Component

The Browser Capabilities Component can be used to create a BrowserType object that acts as a data collection in an ASP page for providing a description of the capabilities of the client's web browser to the ASP scripts. The function of the BrowserType object is to automate the checking of the capabilities of the user browser against the database each time when an user sents an HTTP request to open or reload the web page. A text file called browser.ini file is used to store the information about the capabilities of browsers. Both new properties or new browser definitions available in the market can be added to database by updating the Browscap.ini file. The mechanism of the function is made use of the HTTP User Agent header sent by the browser when connecting to the web server. The HTTP User Agent header is an ASCII string of the browser identifier and version number. The HTTP User Agent header is then used by the BrowserType object to compare with the entries in the Browscap.ini file. If the BrowserType object finds a matched entry in the Browscap.ini file, the properties of the matched browser in the Browsercap.ini is assumed to be the properties of the connected user Browser and is assigned to the properties of the BrowserType object accordingly. If the BrowserType object cannot find a matched entry for the HTTP User Agent header in the Browscap.ini file, the BrowserType object will try to search for the closest matched entry by using the * and ? wildcards. If the BrowserType object cannot find a closest matched entry for the HTTP User Agent header in the Browscap.ini file, the BrowserType object will use the default browser settings as the properties of the connected user browser if the default browser capability settings is defined in the Browscap.ini. When the BrowserType object cannot find a matched entry or a closest matched entry and default browser settings have not been specified in the Browscap.ini file, the BrowserType object sets every property to the string "UNKNOWN."

File Name

The file name of the Browser Capabilities component is Browscap.dll.

Syntax

Set BrowserTypeName = Server.CreateObject("MSWC.BrowserType")

Parameters

BrowserTypeName

The parameter "BrowserTypeName" is the name assigned to the instance of the BrowserType object created by the call using the Server.CreateObject.

Remark

The Browser Capabilities Component does not work with Internet Information Server 7 (IIS7).

Browscap.ini File

The Browscap.ini File is used to store the default properties of browser setting and the database entries of the properties of browsers for the Browser Capabilities Component. The default value of the properties of browser is used to set the properties of browser when there is no matched entry found in the Browscap.ini file. Any property definitions can be declared for any number of browser in the Browscap.ini file. Each browser definition entry should contain the HTTP User Agent header, and the associated property definitions, that is the name of properties and the corresponding value setting of the properties. For the format of the HTTP User Agent header, the HTTP specification can refer to http://www.w3.org/Protocols/Specs.html for details.

The Browscap.ini File should be stored in the same directory as  the Browscap.dll fille. Each parameter or setting is stroed in one single line. Comments is allowed anywhere  in the Browscap.ini by starting a new line with a semicolon ";", so that the whole line will be ignored by the BrowserType object.  The Browscap.ini File can be divided into two sections. One is for the data entries for any number of browsers. The other is for default entries for the default browser setting starting with the keyword "Default Browser Capability Settings"

The change in a Browscap.ini File may need to restart the IIS services in ordered to make the changes become effective.

Syntax

([; comments])*
([HTTPUserAgentHeader]
[parent = browserDefinition]
(propertyN = valueN)+)*
([Default Browser Capability Settings]
(defaultPropertyN = defaultValueN)+)?

Parameters

[...]

The parameter "[" & "]" is the indicator of the bracketed parameters by a pair of square brackets "[...]" is an optional item unless other specified.

(...)*

The parameter "*" is the indicator of the bracketed property parameters by a pair of brackets "(...)" can be repeated zero or more times.

(...)+

The parameter "+" is the indicator of the bracketed property parameters by a pair of brackets "(...)" can be repeated one or more times.

(...)?

The parameter "?" is the indicator of the bracketed property parameters by a pair of brackets "(...)" can be zero or one time

;

The optional parameter ";" is the indictor of a comment line placing on the starting of a line that will be ignored by the BrowserType object.

comments

The optional parameter "comments" is used to specify the content of a comment on the same line.

[HTTPUserAgentHeader]

The square bracketed parameter "HTTPUserAgentHeader" is used to specify the unique value of the HTTP user agent header of a browser that to be associated with the properties of browser declared in the property parameter. There can be zero or more browser entries in the Browscap.ine file , but each should be starting with a unique HTTPUserAgentHeader value.

When specifying the value in HTTPUserAgentHeader, a asterisk (*) character can be used as a wildcard character to replace zero or more characters and a question mark (?) character can be used as a wildcard character to replace a single character. For example, string in the HTTPUserAgentHeader:

[Mozilla/4.0 (compatible; MSIE 5.0;* Windows NT)]

can be used for matching with the user browsers:

[Mozilla/4.0 (compatible; MSIE 5.0; Windows NT)]
[Mozilla/4.0 (compatible; MSIE 5.0; AK; Windows NT)]
[Mozilla/4.0 (compatible; MSIE 5.0; SK; Windows NT)]

However, the BrowserType object will attempt to match the HTTP User Agent header of the user browser to the value HTTPUserAgentHeader exactly first. if that fails, the BrowserType object will continue the matching process with wildcard characters. When applying the wildcard character, the BrowserType object uses the closest match strategy, the matching of the HTTP User Agent header value of the user browser with the fewest characters replacement to select the closest entry of in the Browscap.ini. Therefore when more than one HTTPUserAgentHeader in the Browscap.ini containing wildcard characters is matched with the HTTP User Agent header of the user browser, the BrowserType object will only return the properties of the HTTPUserAgentHeader entry of closest match.

browserDefinition

The optional parameter "browserDefinition" is used to specify the "HTTP User Agent header" string of a browser that to be referenced as the parent browser. When the optional parameter "browserDefinition" is specified, the properties of the current specified browser will inherit all of the property values declared in the parent browser's definition. And values of these inherited properties can be replaced by a new value through setting the corresponding parameter propety explicitly. These optional parameter is mainly used for defining a new version of a browser from the previous version because a new version usually retains most of the properties of the previous release.

propertyN

The optional parameter "propertyN" is used to specify the name of a browser property that to be set. The name of a browser property must be started with an alphabetic character and cannot excess 255 characters. some possible properties are:

ActiveXControls: to specify supporting ActiveX Controls or not
Backgroundsounds: to specify supporting background sounds or not
Beta: to specify the browser is beta software or not
Browser: to specify the name of the browser
Cdf: to specify supporting the Channel Definition Format for Webcasting or not
Cookies: to specify supporting cookies or not
Frames: to specify supporting frames or not
Javaapplets: to specify supporting Java applets or not
Javascript: to specify supporting JScript or not
Majorver: to specify the major version number of the browser
Minorver: to specify the minor version number of the browser
Parent: to specify the parent browser as defined in Browscap.ini
Platform: to specify the name of the operation system of the browser running on
Tables: to specify supporting tables or not
Vbscript: to specify supporting VBScript or not
Version: to specify the version number of the browser

In the Browscap.ini file, the number of statements of property values can be specified as many as needed in each browser entry. But the Browscap.ini file can also contain only the properties which are needed by the application and should be known whether the user browser supported or not. For example, if an application only supports a Cookies supported browser, the Browscap.ini file only needs one property statment for each browser entry.

[Default Browser Capability Settings]

The square bracketed parameter "Default Browser Capability Settings" is used to specify the unique value of the HTTP user agent header of the default browser that to be associated with the properties of the default browser declared in the property parameter. There can only be one default browser entry in the Browscap.ine file. Usually a single asterisk (*) character is used as the HTTP user agent header for the default browser capability settings so that the default property settings can be applied to any user browser when there is no closest entry is found in the "HTTPUserAgentHeader" section.

Examples

  • Example of making use of BrowserType object to display some of the capabilities of the current browser in a table.

    ASP Page, BrowserType.asp:

    <%
    Set br = Server.CreateObject("MSWC.BrowserType")
    %>
    <TABLE BORDER=1 CELLPADDING=4>
       <TR>
       <TD>ActiveX Controls</TD>
       <TD><%= br.ActiveXControls %></TD>
       </TR>
       <TR>
       <TD>BackgroundSounds</TD>
       <TD><%= br.BackgroundSounds %></TD>
       </TR>
       <TR>
       <TD>Browser</TD>
       <TD><%= br.browser %>
       </TR> 
       <TR>
       <TD>Cookies</TD>
       <TD><%= br.cookies %></TD>
       </TR>
       <TR>
       <TD>Frames</TD>
       <TD><%= br.frames %></TD>
       </TR>
       <TR>
       <TD>JScript</TD>
       <TD><%= br.javascript %></TD>
       </TR>
       <TR>
       <TD>Tables</TD>
       <TD><%= br.tables %></TD>
       </TR>
       <TR>
       <TD>VBScript</TD>
       <TD><%= br.vbscript %></TD>
       </TR>
       <TR>
       <TD>Version</TD>
       <TD><%= br.version %></TD>
       </TR>
    </TABLE>

    HTML web page ouput:
    ActiveX Controls False
    BackgroundSounds False
    Browser Default    
    Cookies False
    Frames False
    JScript False
    Tables True
    VBScript False
    Version 0.0
  • Example of Browscap.ini File with parent tag and default browser settings

    Text in the Browscap.ini File, Browscap.ini:

    ;;ie 5.0
    [IE 5.0]
    ActiveXControls=TRUE
    backgroundsounds=TRUE
    beta=False
    browser=IE
    cookies=TRUE
    frames=TRUE
    javaapplets=True
    javascript=TRUE
    majorver=#5
    minorver=#0
    tables=TRUEE
    vbscript=TRUE
    Version=5.0
    Win16=False
    AK=False
    SK=False
    AOL=False

    ;;ie 5.x
    [Mozilla/4.0 (compatible; MSIE 5.*; Windows NT)]
    minorver=0
    parent=IE 5.0
    platform=WinNT
    version=5.00

    ; Default Browser Settings
    [*]
    browser=Default
    frames=FALSE
    tables=TRUE
    cookies=FALSE
    backgroundsounds=FALSE
    vbscript=FALSE
    javascript=FALSE

Retrieving Browser Capabilities from a Cookie For IE

In IIS 5.0, the client capabilities can be determined through retrieving a cookie, BrowsCap, describing browser capabilities of the user obtained by the javascript STYLE behavior as part of the request from the client initiated by a METADATA#metatag, the ASP page can then create an instance of the Browser Capabilities component that adds the name value pairs specified by the cookie as properties of the BrowserType object.

However, this technique does not work with file redirected from Server.Transfer or Server.Execute methods because the METADATA#metatag in the redirected file will be ignored by the IIS if the file is a redirection from a Server.Transfer or Server.Execute methods and while other parts of the file will be processed normally.

For example, a file, createcap.asp is used to create an instance of the BrowserType object of the browser capabilities of the user browser and display the browser capabilities of the user browser on the web page. In order to retrieving the cookie from the user browser, an additional file, getcookie.htm is needed to run on the client and determine the list of browser capability properties of the client using DHTML. And the technique used to run the file, getcookie.htm automatically on the client is by inserting a METADATA#metatag before running the contents of the file.

Browser Capabilities displaying ASP Page, createcap.asp:

<!--METADATA TYPE="Cookie" NAME="BrowsCap" SRC="getcookie.htm"-->
<HTML>
<BODY>
<% Set br = Server.CreateObject("MSWC.BrowserType") %>
<%
Response.write("width= "+br.width+ "<BR />")
Response.write("height= "+br.height+ "<BR />")
Response.write("bufferDepth= "+br.bufferDepth+ "<BR />")
Response.write("colorDepth= "+br.colorDepth+ "<BR />")
Response.write("cookies= " +CStr(br.cookies)+ "<BR />")
Response.write("platform= "+br.platform+ "<BR />")
%>
</BODY>
</HTML>

Browser Capabilities retrieving WebASP Page,  getcookie.htm:

<HTML>
<SCRIPT language="JavaScript">
function removeErrors()
{
// Remove all errors.
return true;
}
window.onerror = removeErrors;
function window.onload ()
{
bdBrowsCap.style.behavior = "url(#default#clientCaps)";
brString = "width= " + bdBrowsCap.width;
brString += "&height= " + bdBrowsCap.height;
brString += "&bufferDepth= " + bdBrowsCap.bufferDepth;
brString += "&colorDepth= " + bdBrowsCap.colorDepth;
brString += "&cookies= " +bdBrowsCap.cookieEnabled;
brString += "&platform= " + bdBrowsCap.platform;
document.cookie = "BrowsCap= " + brString;
}
</SCRIPT>
</HEAD>
<BODY ID="bdBrowsCap">
</BODY>
</HTML>

Previous Month  FEB  2013  Next Month
SMTWTFS
12
3456789
10111213141516
17181920212223
2425262728

Previous Month  SEP  2016  Next Month
SMTWTFS
123
45678910
11121314151617
18192021222324
252627282930

Sideway BICK Blog

11/02


Copyright © 2000-2020 Sideway . All rights reserved Disclaimerslast modified on 26 January 2013