Definition of Web Application

Source: Internet
Author: User
Tags date arrays empty iis parent directory tostring valid versions
web| Program

Web application (Web application) terminology has been used many times in previous chapters to refer to neither a real web site nor a traditional application. In other words, it is a collection of web pages and other resources that are used to accomplish certain tasks. It implies that there is a predefined route throughout the Web page where users can make choices or provide information to enable tasks to be completed.
For example, an online store where you make repeated observations and selections to purchase goods, browse a series of web pages, collect the required information, pay the corresponding fee, and finally issue an order. It may also be a software Upgrade wizard that guides users through the process of downloading and installing new software, or perhaps a build tool that is based on an intranet quote or Sales report.
All of these are different from "standard" web sites, where a typical Web site uses a series of menus or navigation bars to roam the site with a predefined path. But a Web application is far more than just a controlled navigator. When roaming freely on a Web site, stateless and anonymous access can be made, but Web applications are generally not accepted.

3.2.1 The definition of ASP applications
The above can be considered a reasonable general definition of the term "Web application", but unfortunately, this is not enough when talking about "ASP applications." The answer to what is "Web application" can be subjective, and the answer to what is "ASP application" requires a technical explanation. In the ASP, the term "application" has its own specific meaning, and it is essential to understand this concept before discussing how to implement it.
ASP applications are related to two main content:
· Global scope, with a globally accessible variable storage area.
· By integrating COM + with IIS, you can better manage your components.
These are discussed below. The second content is related to other ASP object, its coverage scope is corresponding extensive. This section is discussed in detail in the next chapter when you study ASP server objects.
1. Provide a global scope for Web applications
ASP provides a application object that is essentially equivalent to the Session object discussed earlier. However, this is at the application layer rather than at the user layer. In other words, the object is global, not to individual users, but to all users of the application, whose scope is not limited to the access of individual users. This is the same as a global (or public) variable in a normal executable application. The Application object can be used to store variables and information (that is, state) in the global environment, which can be accessed by scripts running in any ASP Web page within that application, regardless of which visitor makes the request.
However, this does not answer the main question: What is an ASP application? In order to do this, we need to study some cases inside ASP.
When a user requests an ASP Web page, IIS creates an environment (as described in chapter 1th) by instantiating Asp.dll (used to implement ASP). The page is interpreted as a server-side script, and an instance of the corresponding script engine is used to execute the script.
Instantiated Asp.dll as an event starts an ASP application and creates a Application object. Then, start a session for this user and create a separate sessions object. When more sessions are started, the Application object remains in scope (that is, it is already instantiated and available). Once the session that is last kept active ends, the application ends and the corresponding Application object is canceled.
(1) The default ASP application
Windows 2000 creates a default Web site when you install IIS and ASP. It is configured as an ASP application, involving some settings for the site root folder (default C:inetpubwwwroot) in the Properties dialog box. Figure 3-2 shows the screen of the Properties dialog box for the default Web site.

One of the files that involves an ASP application is Global.asa. This file is used to customize the way the application behaves. Placed in the root directory of the application, available for all subdirectories under that directory. Therefore, if it is placed in the root directory of the entire Web site, the entire Web site is defined as part of the default ASP application.
You will see this file and how it is used later in this chapter for application and session events.
(2) ASP virtual application
As with creating a default application during Setup, you can create your own ASP virtual applications in any subdirectories of that Web site. This application contains all subdirectories in the directory defined as the application directory. Also, this directory and subfolders are part of the default application, sharing the global space created by the default Application object.
In fact, all variables stored in the default application are also available in applications in subdirectories. However, if an ASP page in the subdirectory application writes a value to the Application object, and the Application object has the same name as a value already in the default (root) application, the original value cannot be used in the subdirectory application. However, in other applications or ASP pages, the original values are preserved because the root directory application cannot access the values in the subdirectory application.
Consider this problem from the perspective of a subroutine or a variable of a function. If you define a variable intmyvalue as a public or global variable, you can access the variable from within any subroutine or function. However, if you declare a local variable with the same name and reference the variable within that subroutine or function, you get the local value of the variable. The original value cannot be accessed again. When a subroutine or function ends, local values are undone, and the original values of the global variables remain:
Public Intmyvalue = 42
Function dosomething ()
Response.Write Intmyvalue ' gives from global variable
Dim Intmyvalue
Intmyvalue = 17
Response.Write Intmyvalue ' gives from new to local variable,but
' The global value of myvalue is still 42
End Function
(3) Create your own ASP virtual applications
To create a new virtual application, use an Internet Services Manager application or an HTML Web Manager Web page with the same functionality. In Internet Services Manager, right-click on the directory of the virtual application you want to create, select New, and then select Virtual Directory, as shown in Figure 3-3:

This operation launches new Virtual Directory Wizard, which provides information about the operation of the wizard at the Start screen. Click Next, and in the second page, type the name (or alias) of the new virtual application. This name, combined with the path to the directory selected in Internet Services Manager, becomes the URL for the application. The screen looks like figure 3-4:

To convert an existing directory to an application that has the same name as the directory, select the directory that contains the directories you want to convert and use the directory name in the wizard's virtual directory alias page. For example, to convert an existing test directory to a virtual application, you should select the default Web site entry in Internet Services Manager and provide an alias, "Test."
Click Next to specify the path to the content (page) that contains the application. Click Browser to select an existing directory. This directory is the directory that the new virtual application points to. The screen looks like figure 3-5:

Click Next to open the Access Permissions page and select the permissions given to all users of the application. The default values are read and run Scripts, which are appropriate for most users. The screen looks like figure 3-6:

If you want to write a custom compiled CGI application that users can execute directly, select only "execute": for example, an. exe file that a user executes by specifying a corresponding name in the URL of the request, such as " Application/create_user.exe?user=jjones ".
Click Next, and the wizard creates the virtual application. In the screen shown in Figure 3-7, you can see an open small box icon with a few padding in the left column.

If you now right-click a new application and select Properties, you can see the settings that the wizard has selected. Here you can modify access rights, "local Path" and "Application Settings" as needed. You will also see a remove button that can be used to delete the virtual application, as shown in Figure 3-8:

(4) Delete virtual applications
Clicking the Remove button does not really delete the entry in Internet Services Manager. Instead, you convert an existing virtual application to a virtual directory. This directory has a "folder" icon with a blue ball, which means that this is not a real directory in the Web site, but a redirect to another folder on the disk. It is accessed in the same way as the virtual application that created it (that is, using the same URL), but not as an application. In other words, it does not support its own application object, but rather inherits the application object of the default Web site or the Application object of another application in the parent directory of that directory.
To remove a virtual application, simply right-click the object in Internet Services Manager and select Delete from the menu that pops up.
(5) What the application stores
The global storage space provided by the ASP Application object can be used to store the following:
· Simple variables, such as strings and numbers (stored as variants, similar to ASP script variables).
· Variant type array, one-dimensional or multidimensional.
· A variable reference to a COM object instance (of type in a variant).
(6) Definition of variant
A variant is a unique variable type that is provided for ASP (and Internet Explorer) in the VBScript scripting engine, similar to the variant of the data type defined in VB and VBA. Compared to most commonly used basic data types, such as strings or integers, the variant provides many uses, although it does not allow the storage unit to store variables most efficiently and requires additional processing.
From within the Variant data type stores numeric values as separate subtypes. It handles implicitly type conversions automatically, allowing the following code to be used:
strstring = "30"
Intinteger = 12
Response.Write strstring & Intinteger ' writes 3012 in the resulting page
Response.Write strstring + Intinteger ' writes in the resulting page
Implicit data type conversions allow you to ignore HTML values in Guangxi and list controls are strings, and you can use them as numbers if necessary (assuming that the string does contain a valid number). You can also do something else randomly, such as using the Len method of VBScript to check the length of a value that does not exist in the Request.Form collection. The Len function attempts to convert the value of a call from Request.Form to a string. If the value is lost, return null (EMPTY) and convert to a string with "", so the length is zero.
(7) VBScript data types and conversions
You can also make explicit data type conversions. In VBScript, the VarType method returns an integer indicating the currently saved subtype of the variant:
Select case VarType (varmyvalue)
Case 0:response.write "Empty (uninitialized)"
Case 1:response.write "Null (no valid data)"
Case 2:response.write "Integer"
Case 3:response.write "Long integer"
Case 4:response.write "single-precision floating-point number"
Case 5:response.write "double-precision floating-point number"
Case 6:response.write "Currency"
Case 7:response.write "Date"
Case 8:response.write "String"
Case 9:response.write "Automation Object Reference"
Case 10:response.write "Error"
Case 11:response.write "Boolean"
Case 12:response.write ' Variant (used only with the items in arrays of variants) "
Case 13:response.write "Data-access Object"
Case 17:response.write "Bytes"
Case 8192:response.write "Variant Array"
End Select
There are also functions, such as IsArray, IsDate, IsEmpty, IsNull, IsNumeric, and IsObject, that return a Boolean result for a specific subtype. Once you know the subtype of the data, you can convert it to a different variant subtype if the data contained is appropriate. This is useful for the transparency of the code and for checking whether the variable contains legitimate values, and the illegal conversion will result in a run-time error, as shown in the following conversions:
Blnboolean = CBool (varvariant) ' converts to a Variant of subtype Boolean
Bytbyte = CByte (varvariant) ' converts to a Variant of subtype Byte
Curcurrency = CCur (varvariant) ' converts to a Variant of subtype Currency
Dtmdate = CDate (varvariant) ' converts to a Variant of subtype Date
dbldouble = CDBL (varvariant) ' converts to a Variant of subtype Double
Intinteger = CInt (varvariant) ' converts to a Variant of subtype Integer
Inglong = CLng (varvariant) ' converts to a Variant of subtype Long
Sngsingle = CSng (varvariant) ' converts to a Variant of subtype
strstring = CStr (varvariant) ' converts to a Variant of subtype String
(8) JScript data types and conversions
In JScript, some other variable types are similar to VBScript, but there is no variant representing the object. All values are objects, and types are one of the following six data types:
· Undefined: Only a single value indicating that the variable in the request is not declared and created, or if it is implicitly created but has not yet assigned any value. Similar to the empty in VBScript.
· Null: The variable does not contain a valid value. Nothing similar to VBScript.
· Boolean.
· String.
· Number.
· Object.
JScript provides a typeof function that returns a string representing the type of data, for example:
strstring = ' 30 ';
Intinteger = 12;
Response.Write (typeof (Strstring)); Write ' string ' in the resulting page
Response.Write (typeof (Intinteger)); Write ' number ' in the resulting page
Each data type has the ToString method and the ValueOf method, and the ToString method returns the value of the variable to a string, valueof the value of the variable as its original data type.
(9) The cascading and adding problems of JScript
JScript differs in many ways from VBScript, partly because there are no "&" cascading operators available. When the addition operator is used, it first checks the data type of the variable to determine what to do. If all two variables are numeric, the result is the value of the and. If one or two are strings, the result is a cascading of strings:
strstring = ' 30 ';
Intinteger = 12;
Response.Write (Intinteger + Intinteger); Writes in the resulting page
Response.Write (strstring + Intinteger); Writes 3012 in the resulting page
Response.Write (Intinteger + strstring); Writes 1230 in the resulting page
If you add more than two values, see the order in which they are executed. The following code shows the appropriate example:
Intinteger = 12;
Response.Write (Intinteger + Intinteger + "
”); Result is ' 24
Response.Write ("
"+ Intinteger + Intinteger +"
Result is '
In the first case, two numbers are added, and the result is converted to a string and cascaded with the string. In the second case, the first operator is the cascade of a string and a number, so the number is converted to a string. Then, all the operators are a class transport operator. To avoid this problem, you can use parentheses to force the first operator to be an addition of two numeric values:
Response.Write ("
"+ (Intinteger + Intinteger) +"
Result is '
1. Component Management in Web applications
The second major aspect of using virtual applications in ASP is the ability to manage the components that are instantiated and executed within the scripting code. Without discussing the details of how it works and why it is so useful, discuss the content in the part of the ASP component.
This is a very brief introduction of how to set up a virtual application in the Properties dialog box (in Internet Services Manager) when using components in an ASP Web page (in this application).
At the bottom of the home directory page of a virtual application's Properties dialog box, there are two combo boxes for the Execute permissions and application Protection, as shown in Figure 3-9:

Applied protection and execution settings
Because in this chapter, you don't discuss how to create an instance of a component within a Web page, so these options are listed here and you might want to set this up when you create your application. The Execute Permissions option is shown in table 3-1:
Table 3-1 Execute permissions options and descriptions

You cannot run a script or executable file in this virtual application. In fact, it provides a quick and easy way to block an application

Allow only script files (such as ASP, IDC, or others) to run in this virtual application and not run executable files

Scriptsand Executables
Allow any script and executable file to run within this virtual application

The Execute Permissions option controls the types that can be executed in the virtual application, and the Application Protection option affects how the executable files and components run. The options available are discussed in Chapter 1th, but again, the Application Protection option is shown in table 3-2:
Table 3-2 Application Protection options and descriptions

Low (IIS Process)
All executables and components of an ASP virtual application with this setting run in the process (that is, memory space) of the Web server's executable file (Inetinfo.exe). Therefore, if one of the executable files or components fails, the Web server is in a dangerous state. This provides the fastest and most available options for executing with a minimum of resources

Medium (Pooled)
(default) The executable files and components of all applications that have an ASP virtual application with this setting are in a process (that is, memory space) running on a single shared instance of DLLHost.exe. This prevents the Web server executable (Inetinfo.exe) from being affected by the failure of the executable file or component. However, a failed executable or component may cause the DLLHost.exe process to fail, and all other executable files and components that reside in it fail

High (Isolated)
The executable parts and components of all applications for an ASP virtual application with this setting are in the process (that is, memory space) running on a single shared instance of DLLHost.exe, but each ASP application has its own DLLHost.exe instance, which is exclusive to the application. This prevents the Web server executable (Inetinfo.exe) from being affected by an executable file or component failure, and prevents a single shared instance of a virtual application from being affected by an executable file or component failure of another virtual application. Microsoft recommends that up to 10 such virtual applications reside on a Web server

3.2.2 ASP Session Definition
ASP sessions introduce the next layer of granularity in a Web application. An ASP's Application object can be used to store the global and accessible state (that is, simple variables, objects, arrays, and so on) for all users who are running this application. In other words, all ASP code that responds to requests from all visitors within this application can access these values (assuming that a valid session has been established and will be seen later).
But in most cases it's not enough. You need to have the ability to store values that are assigned to each user without having to assign a name to those values to indicate which user they belong to. For example, the following values are likely to mess up the application's global storage space:
Mikejones003preffgcolor = "Darkblue"
Mikejones003prefbgcolor = "White"
Priscilladelores001preffgcolor = "Red"
Priscilladelores001prefbgcolor = "Darkgrey"
There are additional drawbacks from the point of view of loading system resources and requiring some code to access each user's corresponding session. The application persists as long as there is a visitor, which means that the application's global storage space needs to grow, unless the user takes steps to remove the values when they leave the site.
Providing a user-layer scope in a Web application
In addition to storing with global variables, each visitor should be assigned their own private variable storage space to make it available to all pages that the specified visitor loads. In this case, you can use the same name for each variable, making the ASP code very simple to implement. These same code will work transparently for each user, because access is only the private storage area owned by the visitor:
Preffgcolor = "Darkblue"
Prefbgcolor = "White"
Preflinkcolor = "Green"
This is where the session object is created.
(1) Content of Session storage
The content of the session store is global to the specified audiences and is private to other visitors, which makes the ASP's session very useful. can be used to store the same type of data stored in an ASP Application object, namely:
· Simple variables, such as strings and numeric values (stored as variants, like all ASP script variables).
· Variant Array, one-dimensional or multidimensional.
· A variable reference to an instance of a COM object (as a variant).
(2) problems caused by conversation
A session provides a way to store each user-specific value. However, there are a few unexpected questions to note:
· Remember that some browsers and Web servers are sensitive to the case of URLs, paths, and filenames (such as navigator and unix/linux based servers). If you place a hyperlink on a URL of a Web page and they are not the same writing form, they are considered different in the browser. Similarly, if the path and file name are not written the same way, the browser considers a different path or file. This is not important for locating resources on the server, because IIS is insensitive to writing, can accept any combination of uppercase and lowercase forms, and returns files with the same character as different writing forms. However, if a cookie has already specified a path, and the path specified in the hyperlink differs in writing, the browser may not return it to the server along with the corresponding directory page. This may not be able to find a user session that relies on this cookie, and the sessions object will not be in scope (that is, any of these variables are not available). Therefore, in all directories and web names, it is a good idea to stick to lowercase or more obvious mixed-letter forms.
· In earlier versions of IIS and ASP, there are also small "bugs" for nested applications, and sometimes, when a user leaves a nested ASP virtual application and returns to the default ASP application layer, any global variable with the same name as the local variable already defined within the nested application cannot be displayed again. Also, the code in the Global.asp file fails when the session terminates using the Session.Abandon method (which will be seen later). These issues have been addressed in ASP 3.0.
· Remember that the session relies on cookies. If the visitor has disabled cookies or the browser does not support cookies, you will not be able to start a session and cannot access the sessions object.
(3) Prohibit session
Although the State provides a beneficial environment, it makes the user portal open. If you do not need to preserve the state, you can block sessions to conserve computer processing time. For example, on a Web site that does not need to track visitors or keep global values for visitors, you can prevent the session from starting, by setting properties in Internet Services Manager, or by adding code to a stand-alone page that does not require status (see later).
To disable all sessions of the entire Web site, you can edit the properties of the default Web site application. To prevent a session of a specified application, you can edit the properties of the corresponding virtual application. Open the Properties dialog box for the appropriate application and click the Configuration button on the Home Directory page, as shown in Figure 3-10:

In the Configuration dialog box that appears, open the app Option. This allows or disables the entire application's session (in this case the entire default Web site), or modifies the default session timeout value. You can see in figure 3-11 that the timeout is set to 20min. This is the default value in earlier versions of the ASP, and you can set the appropriate value (in ASP 3.0, the default value is 10min).

If you want to prevent a session of a specified Web page and allow them to be created and used in other pages of the same application, you can add an ASP processing instruction to the page. It follows a statement that specifies the default language (if you do not specify a default language, you can use the directive separately):
<% @LANGUAGE = "VBScript" enablesessionstate= "False"%> this concludes with an overview of some of the scenarios for ASP applications and session objects, discussed in detail below.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.