Understand these points, you will learn Web programming

Organized and referenced from "Liu Xin Programmer " 

 

1. Understand the browser/server structure (B/S)
B/S is developed from the client/server side in the 1990s, and the common point is that one (or a group) server serves multiple clients. 
The difference is: First, the client of the C/S structure may be written in different languages, such as VB, Delphi, PowerBuilder, etc. In the B/S structure, the browser has become a general client, and the program is presented in the form of Web, No installation is required, and the server-side upgrade means all client-side upgrades, which is an earth-shaking change compared to C/S.
Secondly, the access protocol of B/S is also standardized as HTTP(s), rather than the original various private protocols.
Finally, the server in the B/S structure is accessible to users around the world, not just a local area network like C/S, so the pressure is greater and the challenge is greater.
2. How is the Web page composed?

Simply put, it is HTML + CSS + Javascript, and the web interface we see is composed of these three.
HTML is responsible for structure, CSS is responsible for presentation, and Javascript is responsible for behavior.
The front-end development we are talking about is mainly to do this. For front-end engineers, they need to be able to understand the DOM model and how to operate the DOM model through javascript (such as JQuery and other frameworks). 

3. How do browsers and servers deal with each other?

Of course it's HTTP! HTTP, to put it bluntly, is an agreement between the browser and the server to chat, and this agreement ensures that both parties understand each other. The complete HTTP is very complex, and the book "The Definitive Guide to HTTP" is over 700 pages thick. In fact, the most commonly used and most important points are as follows:

  1. GET and POST. GET gets data from the server, and POST sends data to the server (this leads to the problem of image uploading)
  2. HTTP is a stateless protocol and requires additional mechanisms to maintain state (such as login status), the most commonly used method is cookies.
  3. Understanding HTTP Status Codes
  4. Understand synchronous vs asynchronous (which leads to AJAX, and frameworks such as JQuery)

4. Mapping of URL and code

Understand the relationship between url and code, for example, how does a url such as www.xxx.com?action=login relate to the back-end business code? Where are such rules defined? In code, annotations or configuration files? How should the back-end business code be organized? I believe that no one will write business logic into Servlet now, so many MVC frameworks like Struts and SpringMVC are needed to organize the code and make the system clear and easy to understand.

5. Data validation, conversion and binding

How to ensure that the data sent by the browser meets the requirements?

  • For example, it cannot be empty, no more than 8 characters, the two passwords must be equal.... If there is an error, an error message must be given.
  • The data sent by the browser are all simple texts such as username=liuxin&password=123456, but the background program has rich data types, such as String, Date, Integer and so on. So you need to turn the text into the type of the specified language.
  • After type conversion, how can the back-end business code be used effectively?
  • The easiest way is to get a map like key:value, and the business code can use map.get(key) directly.
  • The advanced ones can directly bind the data sent by the page to the properties of the object, and support complex structures such as arrays and nesting.
  • For example user.name=liuxin&user.password=123456 can be bound to an object called User, which has two properties userName and password. 

6. Web Security

How to prevent hackers from using SQL injection, cross-site scripting attacks, cross-site request forgery and other means to attack the system?

7. Database access

This piece is more troublesome, after all, there is a natural gap between the object-oriented (OO) world and the relational (Relational) database.

For simple applications, it is enough to write some JDBC directly, and you only need to master the three basics of Connection, Statement and Resultset. 

Complex points need to be done with O/R Mapping frameworks, such as Hibernate, MyBatis, and RoR's ActiveRecord.

The tricky part of this is the association between tables , the so-called one-to-many, one-to-one, and many-to-many relationships, how to describe them in the object-oriented world.

To expand, you also need to deal with connection pools, transactions, locks and other annoying problems.

8. What technologies are used to generate Web pages?

The Web page mentioned here is the page in point 2, including HTML, CSS, and Javascript. 

Can I directly output HTML using Servlet's PrintWriter? Of course, but no one will understand it in the future.

There are many technologies used to create Web pages today: such as JSP, Velocity, Freemaker, Groovy, etc. They all have one thing in common:  templating technology .

To put it bluntly, there is an HTML template in which code can be embedded. This template can generate a Web interface with different content according to the input at runtime (for example, in Tomcat).

Regardless of the template, an important question needs to be faced: how to display the data sent from the business logic layer? This step is actually closely related to the data binding in step 5. Because this step needs to determine the field names such as user.name, user.password.

9. How to convert objects into XML or JSON strings?

Due to the existence of AJAX and mobile phones, for a URL request, the return value they require is usually not an HTML page, but XML or JSON data. At this time, a framework needs to convert the object into a corresponding string. After you have mastered the basics of the Web, it should be no problem to be a Web programmer in the company. The next thing you need to learn is advanced content such as high concurrency, caching, search, and distribution.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325090781&siteId=291194637