ASP Tutorials - Herong's Tutorial Examples - v5.10, by Dr. Herong Yang
Controlling Response Header Line Example
This section provides tutorial example on 2 ways to control HTTP response header line in an ASP script page: Using response.ContentType and response.Charset properties; and using response.AddHeader() method.
Now, I know that my HttpRequestGet.java works correctly. Let me use it to view ASP tutorial examples to show you 2 ways to control HTTP response header lines described in a previous section.
The first example, set_content_type.asp, uses the special properties of the response object:
<script language="vbscript" runat="server"> ' set_content_type.asp ' Copyright (c) 2002 by Dr. Herong Yang response.ContentType = "text/plain" response.Charset = "ISO-8859-1" response.Write("<html><body>Hello world!</body></html>") response.End() </script>
The response:
HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Date: Sat, 28 Dec 2002 23:05:34 GMT Connection: Keep-Alive Content-Length: 38 Content-Type: text/plain; Charset=ISO-8859-1 Set-Cookie: ASPSESSIONIDQGQQGVCU=PMOHPEODJIKOLILLKJICNNPI; path=/ Cache-control: private <html><body>Hello world!</body></html>
Note that the Charset property is used as a parameter in Content-Type header line.
In the second example, add_header.asp, I am trying to use the generic methods to add various header lines:
<script language="vbscript" runat="server"> ' add_header.asp ' Copyright (c) 2002 by Dr. Herong Yang response.AddHeader "Content-Type", "text/xml;charset=UTF-8" response.AddHeader "Author", "Herong Yang" response.AddHeader "Author", "Joe Wang" response.Write "<html><body>Hello world!</body></html>" response.End </script>
Here is the response:
HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Date: Sat, 28 Dec 2002 13:46:53 GMT Content-Type: text/xml;charset=UTF-8 Author: Herong Yang Author: Joe Wang Connection: Keep-Alive Content-Length: 38 Content-Type: text/html Set-Cookie: ASPSESSIONIDQGQGGOSU=IEBDDENBHEFCBLJJKDKAKICH; path=/ Cache-control: private <html><body>Hello world!</body></html>
Note that:
Table of Contents
ASP (Active Server Pages) Introduction
IIS (Internet Information Services) 5.0
Managing Sessions with and without Cookies
scrrun.dll - Scripting Runtime DLL
►Managing Response Header Lines
Controlling Response Header Lines
Response Header Lines for Static Files
►Controlling Response Header Line Example
Sending Binary Files to Browsers
Calculation Speed and Response Time
Working with MS Access Database