Starting from the nature of dynamic web pages (1)

Source: Internet
Author: User
Tags website server

Today, dynamic web pages are everywhere on the Internet. Learning to create web pages cannot escape the process of creating dynamic web pages. However, I found that some friends who are learning web programming do not really understand some basic issues, so they often go wrong when thinking about problems. I would like to give some specific explanations and clarify some facts for dynamic web pages.

Dynamic Web pages have two internal spaces

In fact, I want to say that the server and client in the dynamic web page exist in two time spaces-this is the most fundamental problem. Some people may think that I have a big question. But I found that too many beginners do not understand this point, and this is the basis for understanding everything else, so I have to focus on it first.

First, static Web pages can be simply understood as HTML files. They contain elements to be displayed on the interface and some Javascript script programs. When a user enters a website, the browser sends a request to the server of the website, and then the server will respond and send the webpage content to the user's computer, the browser downloads the webpage and displays it. The javascript contained in the webpage also runs in the browser on the client's computer. As a result, users can see a variety of webpage content.


Today, static users feel that they are not enough to use the dynamic web page technology. It is between the server's acceptance of the request and the response. Take the representative ASP as an example. An ASP page not only contains normal HTML page code, but also adds many server scripts (usually VBScript ). The entire process is more complex than static web pages:

1.The client sends a request.: The user enters a URL and the client sends a request to the website server.

2.Server RunningThe server finds that the client requests an ASP page, so it runs the server script in ASP, that is, the part between "<%" and "%>. The result of ASP page running is a static html page

3.Server Response: The server sends the temporary static page to the client.

4.Client Download Page: The address of the ASP file is displayed in the address bar of the client browser, but the result is a static page that has been processed by the server.

5.Client running script: This static page may still contain JavaScript scripts, which are run in the client's browser.

Server scripts (VBScript in ASP) run on the website server, while HTML code and client scripts (usually JavaScript) run on the client computer. Be sure to understand this: they are completely independent! They do not know each other's meaning. For the server, it only focuses on the server-side scripting program between "<%" and "%>", and it is only responsible for running them, and put the results back to the original place, and arrange them together with other common HTML code and javascript programs to become part of them.

For the user's browser, the web pages it obtains have no server scripts, because those scripts have been executed by the server before. The browser can see a clean HTML page. It only needs to display the page intently and run the Javascript in it.

Therefore, server scripts cannot exchange data directly with client scripts. Although they are written on the same page, they are completely in two spaces and cannot run together.

A dynamic web page is actually a server "function"

This may be a stranger. It is a coincidence that I know dynamic web pages. Let's take a look at the process of dynamic web pages. I simplified the process and considered the webpage relationship before and after it:

1. The customer is browsing web page A. Click the link or submit button to switch to dynamic web page B. In this case, the browser will include some information entered by the user in the "request" of dynamic web page B and send it to the server.

2. The server receives the request, analyzes the information, and runs the server script section of dynamic web page B to generate the result HTML page.

3. the server sends the result HTML page to the client as a response. The client displays this webpage.

Let me analyze it carefully. When the previous web page turns to the next dynamic web page, it will submit some information, such as our common address "http://www.abc.com/index.asp? Id = 123" "Id = 123" in is some data submitted to index. asp in get mode. Forms that can be seen everywhere on webpages are also submitted to dynamic pages in post mode. This data can be obtained by server scripts on the dynamic web page, so I regard it as a "parameter ". The server script in the dynamic web page starts execution after obtaining the parameters to form a result page, which is usually an HTML page. Then the server returns the result page to the client, and I regard it as "return value ".

Therefore, the entire process of dynamic web pages is like a function far away from the server, but its calling method is very special.

 

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: info-contact@alibabacloud.com 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.