Understand these points, you learn the Web programming

Source: Internet
Author: User

Collation reference from "Liu Xin program Ape "

1. Understanding Browser/Server structure (b/s)
b/S is from the 90 's client/server development, the common denominator is a (or a group of) server to serve multiple clients.
The difference is: First, C/s structure of the client may be written in different languages, such as Vb,delphi, PowerBuilder and so on, b/s structure in the browser has become a common client, the program is presented in a web-based way, do not need to install, Server-side upgrades mean all clients are upgraded, which is a huge change compared to the C/S.
Second B/S Access protocol is also standardized to HTTP (s), rather than the original various private protocols.
Finally, the server in the B/s structure is accessible to global users, not just the local area network like C/s, so the pressure is greater and the challenge is greater.
2. How is the Web page composed?

In simple terms, HTML + CSS + Javascript, the Web interface we see is made up of these three.
HTML is responsible for the structure, CSS is responsible for presentation, and JavaScript is responsible for behavior.
We say that the front-end development is also mainly to do this piece, for front-end engineers, need to be able to understand the DOM model, and how to manipulate the DOM model through JavaScript, such as the framework of jquery.

3. How do browsers and servers deal with it?

Of course it's HTTP! HTTP is the idea that the browser and server chat is a convention that ensures that both parties understand each other. Full HTTP is very complex, and the HTTP authoritative guide is more than 700 pages thick. In fact, we are most commonly used, but also the most important points are:

    1. GET and POST. Get data from server side, post send data to server (this leads to picture uploading problem)
    2. HTTP is a stateless protocol that requires additional mechanisms to maintain state (such as login status), and the usual method is a cookie.
    3. Understanding HTTP Status Codes
    4. Understanding Synchronous vs Async (which leads to Ajax, and frameworks such as jquery)

4. URL and Code Mapping

Understand the association between URLs and code, such as how URLs like Www.xxx.com?action=login are associated with back-end business code? Where is such a rule defined? In code, annotations, or configuration files? How is the business code of the backend organized? Believe that no one is writing business logic into the servlet now, so many MVC frameworks like struts, SPRINGMVC to organize the code to make the system clear and understandable.

5. Verification, conversion and binding of data

How to ensure that the data sent by the browser is in accordance with the requirements?

    • For example, cannot be empty, no more than 8 characters, two passwords must be equal ...., error prompt.
    • The data sent by the browser are simple text such as username=liuxin&password=123456, but the background program has a rich data type, what string, Date, Integer and so on. So you need to turn the text into the type of the specified language.
    • After the type conversion, how can the backend business code be used effectively?
    • The simplest is to get a key:value this kind of map out, business code directly with Map.get (key) can be.
    • Advanced point of the page can be sent to the data directly bound to the properties of the object, and support arrays, nesting and other complex structures.
    • 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, the direct write point JDBC is sufficient, only need to master connection, Statement, resultset these three foundations.

Complex points need to be done with the O/R Mapping framework, such as Hibernate, MyBatis, and Ror ActiveRecord.

The tricky thing about this is the association between Tables , the so-called one-to-many, one-to-one, many-to-many relationships, and how to describe them in an object-oriented world.

Extension, you also need to deal with connection pooling, transactions, locks and other annoying problems.

8. What technology is used to generate Web pages?

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

Can I directly output HTML directly from the servlet's printwriter? Of course, but no one can read it later.

There are a plethora of techniques for creating Web pages: JSP, Velocity, Freemaker, Groovy, and so on, they all have one thing in common: template technology .

To put it bluntly, there is an HTML template in which you can embed code that, at run time (such as in Tomcat), can generate a different content Web interface depending on the input.

Regardless of the template, you need to face an important question: How to show data sent from the business logic layer? This step is actually closely related to the data binding in step 5th. Because this step needs to determine the field names such as User.Name, User.password.

9. How do I turn an object into an XML or JSON string?

Because of Ajax and the presence of a mobile phone, for a URL request, the return value they require is usually not an HTML page, but rather XML or JSON data, at which point the framework needs to convert the object to the appropriate string. Take care of the web these basic things, in the company to do a web programmer should be a cinch, the next thing to learn is like high concurrency, caching, search, distributed and other advanced content.

Understand these points, you learn the Web programming

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.