Hello, welcome toPeanut Shell B2B Foreign Trade Network_Professional B2B E-commerce Platform_Free B2B Information Publishing Network!
18951535724

Web core technology analysis: fundamentals (ii)

   2026-11-05 NetworkingName1290
Key Point:Dynamically generated pagesNow we know how to access a simplest static page. So think about how this page was developed: HTML documents are text materials that can be spelled out in the notebook. So if there's 10,000 stories on the news site, do we need 10,000 HTML files? Or does sina weibo have 100 million users and do we need to prepare 100 million homepage documents? The answer is clearly no。We can imagine that there might be a template

Dynamically generated pages

Now we know how to access a simplest static page. So think about how this page was developed: HTML documents are text materials that can be spelled out in the notebook. So if there's 10,000 stories on the news site, do we need 10,000 HTML files? Or does sina weibo have 100 million users and do we need to prepare 100 million homepage documents? The answer is clearly no。

We can imagine that there might be a template for a web page where the server fills out the news that the user would like to see in a web template at the request of the user; or, when you look at the home page of a large v microblog, the server dynamically places the tweets and comments of the big v on a web page。

If we can understand that, then we can think of itServerend, there is a program that specializes in the dynamic generation of web-based documents, which can be called an application server or a back-end program。

Theoretically, most programming languages can be used to develop dynamic web pages, but in practice some languages are particularly good at doing this, such as php, jsp, which is quick, efficient and, in exceptional cases, lightweight web pages and small websites. The most popular website development languages are php, java, python, etc。

There are two concepts here to emphasize。

First, most of the web pages on the internet, such as news, microblogging, forum posts (even if you think they have a file called **. HTML), are not kept on the website server in the form of specific documents, that is, they may not exist. Rather, at the end of the server, the program is dynamically generated at the request of the user。

Second: while back-end programs are able to organize information dynamically, for a specific http request, back-end programs that are generated and sent to users by the server are still a static HTML document. For browsers, it does not really judge whether HTML documents are static or dynamic-generated documents, which appear to be static documents. It can be argued that back-end programs are isolated from users。

For example, php is a very flexible back-end language where you can insert a php code directly into the HTML file, or you can output all HTML codes with php。

Step1. Assuming that there is a page template for hello. HTML with a php code embedded, he does so before the server end is executed。


This is the static part of the page

Today is ". Date." ♪ it's all right ♪

Step2. User launched the http request to visit hello. HTML. The web server found the file, but found an unknown php code and called the php process. Php is an explanatory language that runs php code by line:

Step3. When php runs, it gets a document full of HTML static labels


This is the static part of the page

Today is 2015/11/21

Finally, a further concept is proposed, and it is logical for back-end programs to dynamically generate web pages. So where is the content of the web page (posts, information) kept? The most common answer is..DatabaseI don't know. For example, e-commerce web sites contain product information, user information and transaction information. The most widely used internet site is mysql (mainly small and medium-sized websites)。

The case of the code used by mysql is described later。

4. Data submission and page update

In the previous subsection, we understood the concept of dynamically generated web pages, and now there is another problem. Assuming it's a news page, how does the back-office program know which article to display? Assuming it's an electrician website, how do you know which product is being displayed

The answer is simple. The user must have told the server. So how did that happen

We know that the user sent to the server via the browser is an http request, so the problem is which part of the http request the user wants to send (known as the parameter bar)。

Request(s)

In the first case, the parameters requested by the user are in the url, which is what we often call the get method. Specifically, the parameter that the user wishes to send to the server is sent to the server in a string, following a certain format, adjoining the url。

For example, if you open the first page, enter "HTML" in the search bar and ask questions about HTML, the page will be refreshed and then the address bar will be changed to a web address? This is the sign that the get parameter starts, & is the separator between the parameters, type and q is the parameter name, qastion and HTML is the parameter value, indicating that the type of query is the problem and the key word for the query is "HTML"。

This is a complete http request

Get /search? Type=q
host: www. Zhihu. Com
connection: keep-live
user-agent: mozilla/5. 0 (windows nt 6. 2; wow64) applewebkit/537. 11 (kHTML, like gecko) chrome/23. 0. 1271. 97 safari/537. 11
accept: text/HTML, application/xHTML+xml, application/xml; q = 0. 9,**; q = 0. 8
referer: https://www. Zhihu. Com/
content-type: application/x-form-urlencoded
content-length: 43
type=qstion&q=http

Of course, because it's not the post that is known to be used on the site, the code is my fiction。

3) expand http header domain

Places user parameters in other headfields or adds a custom headfield. But there is a need for both parties to be compatible, i. E. To agree on a format in advance. This is already part of the expansion of the http agreement, not the usual method。

So to date, we have two methods of communicating user parameters, get and post. In many contexts, both can be used. The distinction and respective characteristics of get and post are not the focus of this paper, and readers are asked to exercise their discretion。

A typical scenario for transmitting user parameters is the form. Let's take an example:

Assume there's a page question. HTML and there's a form on the page:

If you'd like to look at it now, the http code is this:

Name:

Male:Female:

I like to eat:
Apple:
Banana:
Carrot:

The method parameter for form form is defined as get. Fill out the forms, click on submit, and send the following http request:

Get /HTML/HTML form action. Asp? Fname=iherzog&sex=male&food=applehttp/1. 1
host: www. W3school. Com. Cn
connection: keep-live
user-agent: mozilla/5. 0 (windows nt 6. 2; wow64) applewebkit/537. 11 (kHTML, like gecko) chrome/23. 0. 1271. 97 safari/537. 11
accept: text/HTML, application/xHTML+xml, application/xml; q = 0. 9,**; q = 0. 8
accept-encoding: gzip,deflate,sdch
accept-language: zh-cn, zh;q = 0. 8
accept-charset: gbk, utf-8; q = 0. 7,*; q = 0. 3
== sync, corrected by elderman == @elder man

Let's make a difference。

There is a problem here that when you change the value of a component in a form in this so-called user interaction mode, for example, when you fill in a name, change sex, choose a hobby, the browser and the server do not interact until now, and only when you click on submit will the browser wrap up your parameters, that is, the values of the components in the form, into an http request and send them to the server. Furthermore, once sent out, the entire page will be completely updated to the HTML page contained in the response received from the server。

This is known as the http synchronization request (http), a model that presents significant limitations to web functionality in specific web development. As you can see, none of our web pages are like this now, we put a commodity in a shopping cart, and we don't think the whole page will be refreshed, especially when we brush the microblogging, the circle of friends, drag it down and the new content rolls out。

This mode is "http step request " , i. E., does not allow the entire web page to be refreshed, but allows local pages to respond to user requests and load new content. We shall present this in the next chapter。

 
ReportFavorite 0Tip 0Comment 0
>Related Comments
No comments yet, be the first to comment
>SimilarEncyclopedia
Featured Images
RecommendedEncyclopedia
Table of Contents4 sections