Sideway
output.to from Sideway
Draft for Information Only

Content

ASP Miscellaneous Features
  ASP @ Processing Directives
   ASP @ CODEPAGE Processing Directive
     Syntax: Syntax:
     Parameters:
     Remarks:
   ASP @ ENABLESESSIONSTATE Processing Directive
     Syntax:
     Remarks:
   ASP @ LANGUAGE Processing Directive
     Syntax:
     Parameters:
     Remarks:
   ASP @ LCID Processing Directive
     Syntax:
     Parameters:
     Remarks:
     Examples:
   ASP @ TRANSACTION Processing Directive
     Syntax:
     Parameters:
     Remarks:
  ASP Output Directive
     Syntax:
     Parameters:
     Remarks:

ASP Miscellaneous Features

Besides the feature of reusing of the existing codes, ASP technology also provides extra features for setting the process configuration of the ASP engine execution.

ASP @ Processing Directives

In order to have a flexible ASP web application, ASP supports the feature of @ processing directives as optional features. Each ASP page can have an individual control setting for processing  the ASP files. Since each ASP page including included files can only have one single setting and the control setting should be specified before the ASP file  is processed by the ASP engine, the ASP @ processing directives must be the first command within the ASP page, usually placing at the begining of an ASP file to pass information to the web servre on how to process the ASP file and the included files of an ASP page. The five supported ASP @ Processing Directives are

  • @CODEPAGE: to specify the literal strings encoding in a web pagee
  • @ENABLESESSIONSTATE: to turn off session tracking for a web page
  • @LANGUAGE: to set the programing language for interpreting the scripting commands
  • @LCID: to specify the display format of dates, times and currencies in a web page by locale identifiers
  • @TRANSACTION: to specify the scripting command of the ASP page is treated as a transaction for activating the component services to create a transaction for coordinate the resources updating. That is  to specify the ASP file to run under a transaction context

ASP @ CODEPAGE Processing Directive

The @ CODEPAGE directive is used to specify which "codepage" encoding is used to encode  the literal or static strings or the contents of a web page stored in an ASP page. The presenting contents of a web page stored in an ASP page may be written in different language. In general, there is a code page for each language to represent the character encoding of the character set of the language. A character set of an language is a set of digits, alphabets, symbols, punctuation marks, and other glyphs. Code pages are tables of encoded characters mapped to single-byte values or multibyte values for each language. e.g. English is encoded by single byte, Chinese is encoded by multiple bytes. A code page is usually represented by a number. The @ CODEPAGE directive is a write-only option assigned to an ASP page specifically.

Syntax: Syntax:

<%@ CODEPAGE = code page %>

Parameters:

code page

The parameter "code page" is an unsigned integer used to interpret the literal or static strings contents stored in the ASP page. The unsigned integer should be a valid code page or well defined code page for the system in which the ASP scripting engine running.

Remarks:

The default code page of all ASP page is set by the AspCodePage metabase property or by the system ANSI code page implicitly. The @ CODEPAGE directive is used to set the code page of the literal or static strings contents of an ASP page explicitly in a ASP page. Therefore the setting of @ CODEPAGE directive explicitly in an ASP page only affects the literal strings of the stored contents of the ASP page in one single response. While the specifying of the Response.CodePage will only affect the dynamic strings or the HTML output response of the ASP engine in a single response. And the specifying of the Session.CodePage is used to affect dynamic strings for all HTML output responses in a session.

No matter what types of code page setting are specified in the ASP page, there can only be one code page for all the response body or the HTML output response of a web page in the client browser. Incorrect characters are displayed when the code page setting does not match with the character encoding of the response characters. However in order to increase the flexibility of ASP, the code page settings for processing an ASP page are divided into static and dynamic strings. The @CODEPAGE directive is for the code page setting of the static string. And the Response.CodePage or Session.CodePage are for the code page setting of the dynamic strings. The @CODEPAGE directive must be the first command of the ASP page, while the setting of code page by Response.CodePage explicitly can be just done before the response output of the non-literal or dynamic strings by the ASP engine. This is important when literal and non-literal strings are used in the same page especially when static and dynamic strings are used in same command. In general, the code page of @CODEPAGE must match with the code page of Response.CodePage, or literal strings and non-literal strings with different code page setting will display the character incorrectly in either case. Usually, when a web page is created by two asp files, where one file is called by the parent file using #include directive, Server.Execute, or Server.Transferand, the code page of the web page is decided by the parent file of the two ASP pages are set explicitly. The only exception is the using of the Response.CodePage to set the output response explicitly in the parent page before a Server.Execute then the @CODEPAGE directive setting in the child page explicitly can override the code page setting in the parent page.

Since the system default code page will be used when there is no code page setting in a web page, sometimes it is not necessary to set a code page in the web page for those web client with matched system default code page. However, setting the code page for a web page is alway necessary for encoding the response output correctly for all web client in the WWW.

And therefore if the code page is set in a page, the Response.Charset should also be set in order to ensure the response output is displayed correctly for all web client in the WWW.

In order to make the response output display correctly, the file format of a web page must be stored with the same @CodePage setting used in the page. In window, notepad can save files in UTF-8 format or in the system ANSI format. Therefore the ASP file should be saved in UTF-8 format if the @CodePage is set to 65001. Since notepad can save files in system ANSI format according to the default system locale setting in the Regional and Language Options in the Control Panel, notepad can save file in different file format according to @CodePage setting by changing the system locale setting before saving the file.

Similarly, in order to test web pages that use different code pages and character sets in a client computer, the corresponding language packs should also be installed through the adding of language packs in the Regional and Language Options in the Control Panel.

ASP @ ENABLESESSIONSTATE Processing Directive

The @ ENABLESESSIONSTATE directive is used turn off session tracking for a page. By default, the information about requests from a single client is maintained by session tracking.

Syntax:

<%@ ENABLESESSIONSTATE = False %>

Remarks:

If no page response rely on session information, session tracking can be disabled to reduce script processing time.

ASP @ LANGUAGE Processing Directive

The @ LANGUAGE directive is used to specify the scripting language or the script engine that the ASP engine should be used to interpret the script commands in the ASP page. Since ASP engine of Internet Information Server supports both Microsoft VBScript and JScript and other ActiveX compliant scripting languages. In general, both VBScript and JScript can be used as the scripting language for ASP.  The @ LANGUAGE directive is an option, by default, the scripting language is VBScript. If no @ LANGUAGE directive is specified in the script, all script is interpreted by the default VBScript engine.

Syntax:

<%@ LANGUAGE = script engine %>

Parameters:

script engine

The parameter "script engine" is the name of the script engine used to interpret the script or the name of scripting language used in the ASP page. However only two script engines, VBScript and JScript are pre-installed with Internet Information Services (IIS), other types of scripting language should be installed before using.

Remarks:

The default scripting language is VBScript. The default scripting language can also be changed by modifying the IIS Admin Object AspScriptLanguage property. The changes of property can be applied to web service, web server, virtual directory, or web directory.

ASP @ LCID Processing Directive

The @LCID Directive is used to specify the format of dates, times and currencies that the ASP engine should be used to interpret the static or literal strings in the ASP page for different geographical locale. The @LCID Directive is write only.

Syntax:

<%@ LCID = locale identifier %>

Parameters:

locale identifier

The parameter "locale identifier" is a valid locale identifer to represent the locale formatting used for the HTML output. The data type of "LocaleID" is integer. The possible LocaleID are.

LCID Country / Region Language
1078 South Africa Afrikaans
1052 Albania Albanian
5121 Algeria Arabic
15361 Bahrain Arabic
3073 Egypt Arabic
2049 Iraq Arabic
11265 Jordan Arabic
13313 Kuwait Arabic
12289 Lebanon Arabic
4097 Libya Arabic
6145 Morocco Arabic
8193 Oman Arabic
16385 Qatar Arabic
1025 Saudi Arabia Arabic
10241 Syria Arabic
7169 Tunisia Arabic
14337 U.A.E. Arabic
9217 Yemen Arabic
1067 Armenia Armenian
2092 Azerbaijan Azeri (Cyrillic)
1068 Azerbaijan Azeri (Latin)
1069 Spain Basque
1059 Belarus Belarusian
1026 Bulgaria Bulgarian
1027 Spain Catalan
3076 Hong Kong S.A.R. Chinese
5124 Macau S.A.R. Chinese
2052 People's Republic of China Chinese (Default Chinese-Simplified Locale ID)
4100 Singapore Chinese
1028 Taiwan Chinese
1050 Croatia Croatian
1029 Czech Republic Czech
1030 Denmark Danish
1125 Maldives Divehi
2067 Belgium Dutch
1043 Netherlands Dutch
3081 Australia English
10249 Belize English
4105 Canada English
9225 Caribbean English
6153 Ireland English
8201 Jamaica English
5129 New Zealand English
13321 Republic of the Philippines English
7177 South Africa English
11273 Trinidad and Tobago English
2057 United Kingdom English
1033 United States English (Default English Locale ID)
12297 Zimbabwe English
1061 Estonia Estonian
1080 Faeroe Islands Faroese
1065 Iran Farsi
1035 Finland Finnish
2060 Belgium French
3084 Canada French
1036 France French (Default French Locale ID)
5132 Luxembourg French
6156 Principality of Monaco French
4108 Switzerland French
1071 Former Yugoslav Republic of Macedonia FYRO Macedonian
1110 Spain Galician
1079 Georgia Georgian
3079 Austria German
1031 Germany German (Default German Locale ID)
5127 Liechtenstein German
4103 Luxembourg German
2055 Switzerland German
1032 Greece Greek
1095 India Gujarati
1037 Israel Hebrew
1081 India Hindi
1038 Hungary Hungarian
1039 Iceland Icelandic
1057 Indonesia Indonesian
1040 Italy Italian (Default Italian Locale ID)
2064 Switzerland Italian
1041 Japan Japanese
1099 India Kannada
1087 Kazakhstan Kazakh
1111 India Konkani
1042 Korea Korean
1088 Kyrgyzstan Kyrgyz
1062 Latvia Latvian
1063 Lithuania Lithuanian
2110 Brunei Darussalam Malay
1086 Malaysia Malay
1102 India Marathi
1104 Mongolia Mongolian
1044 Norway Norwegian (Bokmål)
2068 Norway Norwegian (Nynorsk)
1045 Poland Polish
1046 Brazil Portuguese
2070 Portugal Portuguese
1094 India Punjabi
1048 Romania Romanian
1049 Russia Russian
1103 India Sanskrit
3098 Serbia and Montenegro Serbian (Cyrillic)
2074 Serbia and Montenegro Serbian (Latin)
1051 Slovakia Slovak
1060 Slovenia Slovenian
11274 Argentina Spanish
16394 Bolivia Spanish
13322 Chile Spanish
9226 Colombia Spanish
5130 Costa Rica Spanish
7178 Dominican Republic Spanish
12298 Ecuador Spanish
17418 EI Salvador Spanish
4106 Guatemala Spanish
18442 Honduras Spanish
2058 Mexico Spanish
19466 Nicaragua Spanish
6154 Panama Spanish
15370 Paraguay Spanish
10250 Peru Spanish
1034 Spain Spanish
14346 Uruguay Spanish
8202 Venezuela Spanish
3082 Spain Spanish - Modern Sort (Default Spanish Locale ID)
1089 Kenya Swahili
2077 Finland Swedish
1053 Sweden Swedish
1114 Syria Syriac
1097 India Tamil
1092 Tatarstan Tatar
1098 India Telugu
1054 Thailand Thai
1055 Turkey Turkish
1058 Ukraine Ukrainian
1056 Islamic Republic of Pakistan Urdu
2115 Uzbekistan Uzbek (Cyrillic)
1091 Uzbekistan Uzbek (Latin)
1066 Viet Nam Vietnamese
1106 United Kingdom Welsh
Remarks:

The local identifier, LCID is a standard international numeric abbreviation for different geographical locale. However, locale identifier is being to be a valid locale identifier after the locale group is being installed on the web server that can be installed through the Regional and Language Options of control panel application. The LCID is also the unique identifier to identify the installed system-defined locales. The two defined LCID of the system is the default locale of the system, LOCALE_SYSTEM_DEFAULT and the individual user's locale setting for the current user, LOCALE_USER_DEFAULT.

The @LCID directive is used to set the locale format of dates, times and currencies for all static or literal strings in a single response explicitly. The locale format is only to specify the display format, not the encoded code. While Response.LCID affects dynamic strings in a single response, and Session.LCID affects dynamic strings in all responses in a session.

And a locale format is always needed for formating the locale format of dates, times and currencies of all static or literal strings in an ASP page. If @LCID directive is not explicitly set in a page, it is implicitly set by the AspLCID metabase property or by the default system locale.

The @LCID directive sets the locale used in an ASP page for both the ASP engine and the scripting engine. But the VBScript function, setLocale only sets the locale used in the script for the scripting engine only. 

Both Response.LCID and Session.LCID can be used to set LCID of dynamic or non-literal static explicitly before displaying formatted output. Therefore if literal and nonliteral output in the same page, the locale of @LCID setting must match with the locale setting by Response.LCID, otherwise the non-literal output may be formatted differently from the literal output.

Since the system default locale will be used when there is no locale setting in a web page, sometimes it is not necessary to set a locale in the web page for those web client with matched system default locale. However, setting the locale for a web page is alway necessary for formating the response output correctly for all web client in the WWW.

And therefore if locale is set in the page,  the code page is also set in a page, the Response.Charset should also be set in order to ensure the response output is displayed correctly for all web client in the WWW. So that the server can encode the page according to the specified code page with the specified locale format before sending the response output to the client and the client can therefore decode the page according to the specified charset correctly.

SSimilarly, in order to test web pages that use different locales, code pages and character sets in a client computer, the corresponding language packs should also be installed in the client computer through the adding of language packs in the Regional and Language Options in the Control Panel.

Examples:
ASP script command:

<%@ LCID=3076 %>
<%Response.LCID=3076%>
<%Response.Write "Response.LCID: " & Response.LCID%><br />
<%Response.Write FormatDateTime("11/01/2001", 1)%><br />
<%Response.Write FormatDateTime("17:41:35", 3)%><br />
<%Response.Write FormatCurrency("1,000")%><br />
<%Response.Write FormatNumber(50, 3, 0, 0, -1)%><br />
<%Response.Write FormatNumber(.02, 3, 0, 0, -1)%><br />
<%Response.LCID=1033%>
<%Response.Write "Response.LCID: " & Response.LCID%><br />
<%Response.Write FormatDateTime("11/01/2001", 1)%><br />
<%Response.Write FormatDateTime("17:41:35", 3)%><br />
<%Response.Write FormatCurrency("1,000")%><br />
<%Response.Write FormatNumber(50, 3, 0, 0, -1)%><br />
<%Response.Write FormatNumber(.02, 3, 0, 0, -1)%><br />
<%Response.LCID=1040%>
<%Response.Write "Response.LCID: " & Response.LCID%><br />
<%Response.Write FormatDateTime("11/01/2001", 1)%><br />
<%Response.Write FormatDateTime("17:41:35", 3)%><br />
<%Response.Write FormatCurrency("1,000")%><br />
<%Response.Write FormatNumber(50, 3, 0, 0, -1)%><br />
<%Response.Write FormatNumber(.02, 3, 0, 0, -1)%><br />

HTTP response output (Buffered):

Response.LCID: 3076
Thursday, 11 January, 2001<br />
17:41:35<br />
HK$1,000.00<br />
50.000<br />
.020<br />
Response.LCID: 1033<br />
Thursday, November 01, 2001<br />
5:41:35 PM<br />
$1,000.00<br />
50.000<br />
.020<br />
Response.LCID: 1040<br />
giovedì 11 gennaio 2001<br />
17.41.35<br />
€ 1,00<br />
50,000<br />
,020<br />

HTML web page ouput:

Response.LCID: 3076
Thursday, 11 January, 2001
17:41:35
HK$1,000.00
50.000
.020
Response.LCID: 1033
Thursday, November 01, 2001
5:41:35 PM
$1,000.00
50.000
.020
Response.LCID: 1040
giovedì 11 gennaio 2001
17.41.35
€ 1,00
50,000
,020

ASP @ TRANSACTION Processing Directive

The @ TRANSACTION directive is used to specify that the script of the ASP page should be treated as a transaction so that Component Services creates a transaction for the script of the ASP and to coordinate the updating of resources related.

Syntax:

<%@ TRANSACTION = value %>

Parameters:

value

The parameter "value" is the type of the transaction support. Possible values are

Required: Always participates in a transaction, and initiates a transaction if one does not currently exist.

 Requires_New: Always initiates a new transaction.

Supported: Participates in a transaction if one exists but does not require a transaction.

Not_Supported: Never participates in a transaction. If called from a script that is using transactions, the script containing the @TRANSACTION processing directive still runs but outside of the context of the transation.

Remarks:

The @TRANSACTION directive must be the very first line in the ASP file, otherwise an error is generated.

The @TRANSACTION directive must be added to each page that should be run under a transaction. The current transaction ends when the script finishes processing.

When an ASP with the @TRANSACTION directive of value equal to Required is called by either the Server.Transfer or Server.Execute method, if the calling ASP file was transacted, the script of the called ASP file continues the transaction of the calling ASP page. And if the calling ASP was not transacted, the called ASP file creates a new transaction.

ASP Output Directive

Unlike the @ Processing directive, the ASP output directive is used to displays the value of an expression or response output  the result of an expression.

Syntax:

<%= expression  %>

Parameters:

expression

The parameter "expression" is the statement of script commands

Remarks:

This output directive is equivalent to using Response.Write to display information or to response an HTML output. 


©sideway

ID: 121200007 Last Updated: 12/30/2012 Revision: 0 Ref:

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019