Chapter 8 - Modifications/Corrections

In Example 8-4, the Application level object must be marked as both threaded or free threaded or an error will occur. Prior to the release of NT 4.0 Service Pack 4.0, you could add an apartment-threaded object to the Application StaticObject collection without an error, though this is not considered a good idea...at all. With the release of SP 4.0, however, adding an apartment-threaded object to the Application's StaticObjects or Contents collections will result in an error.

The following note added during editing did not make it into final copy of the book:

Depending on what version of IIS you are running, whether you are running PWS, or even what NT server pack you currently have installed, trying to assign an apartment-threaded component to an Application collection will lock your Web server to one user session, at best, or could fail completely and generate errors at worst. Application objects should be both-threaded only. Examples 8-9 and 8-10 show access of VB apartment-threaded components from this chapter. For best results 'borrow' both-threaded components from either the Java or the C++ chapters for these examples.

In Example 8-8, add the following two lines of code after the statement directing errors to the error handler:

  Set objContext = GetObjectContext()
  Set objResponse = objContext.item("Response")

In Example 8-12, change the following variable declaration:

  Dim sessnTestObject As test

To:

  Dim sessnTestObject As ResponseTesttest


To assist you with the example, the complete code for Example 8-15, on page 200 is:

Option Explicit

Sub responseCookies()
  Dim objContext As ObjectContext
  Dim rqstObject As Request
  Dim rspnseObject As Response
  Dim x As Variant
  
  ' Access the built-in components
  Set objContext = GetObjectContext
  Set rqstObject = objContext.Item("Request")
  Set rspnseObject = objContext("Response")
Dim cookie As Variant
Dim Key As Variant
For Each cookie In rqstObject.Cookies
   If cookie.HasKeys Then
      For Each Key In rqstObject.Cookies(cookie)
         rspnseObject.Write (cookie + "=" + Key + "=" + _
         rqstObject.Cookies(cookie)(Key))
      Next
   End If
Next
End Sub

In the Further Reading section, replace the following URL:

Microsoft has a reference page on ASP objects, located at http://premium.microsoft.com/msdn/library/sdkdoc/iishelp/iis/htm/asp/introbj_1orp.htm

With:

Microsoft has a reference page on ASP objects, located at http://msdn.microsoft.com/library/sdkdoc/iisref/crtc75kj.htm.