Basic knowledge of javaweb

1. Basic concepts
1.1. Knowledge related to WEB development
  It is used to represent the resources on the Internet host for external access.
  Web resources on the Internet for outside access are divided into:

Static web resources (such as html pages): Refers to the data in the web page for people to browse is always unchanged.
Dynamic web resources: refers to the data in the web page for people to browse is generated by the program, and the content seen when visiting the web page at different time points is different.
  Static web resource development technology: Html
  commonly used dynamic web resource development technology: JSP/Servlet, ASP, PHP, etc.
  In Java, dynamic web resource development technology is collectively referred to as Javaweb.

The running process of the static WEB program: The
  client uses a WEB browser (IE, FireFox, etc.) to connect to the server through the network, and uses the HTTP protocol to initiate a request (Request), telling the server which page I need to get now, all The request for is handed over to the WEB server, and then the WEB server fetches the content from the file system (the disk that stores all static pages) according to the needs of the user. After that, it is returned to the client through the WEB server. After the client receives the content, it is rendered and analyzed by the browser to obtain the displayed effect.

There are several shortcomings in static WEB:

1. The content in the Web page cannot be updated dynamically, and the content and the final effect that all users see all the time are the same.
  In order to make the static WEB display more beautiful, JavaScript can be added to complete some special effects on the page, but these special effects are displayed to the user on the client with the help of the browser, so there is nothing on the server itself. The change

2. Static WEB cannot connect to the database, and cannot interact with users.

1.5. Dynamic Web The
  so-called dynamic does not mean that the page will move. The main feature is: "The display effect of the WEB page changes from person to person", and the dynamic WEB is interactive, and the content of the WEB page can be dynamically updated. The process diagram of the entire dynamic WEB operation is as follows: In the
  dynamic WEB, the program still uses the client and server, and the client still uses the browser (IE, FireFox, etc.), connects to the server through the network (Network), and initiates the request using the HTTP protocol (Request), all current requests are first processed by a WEB Server Plugin (server plug-in), this plug-in is used to distinguish whether the request is a static resource ( .htm or .htm) or a dynamic resource.

If the WEB Server Plugin finds that the client is requesting a static resource ( .htm or .htm), it will forward the request directly to the WEB server, and then the WEB server will retrieve the content from the file system and send it back to the client browser for analysis and execution.

If the WEB Server Plugin finds that the client is requesting dynamic resources ( .jsp, .asp/ .aspx, .php), first transfer the request to the WEB Container (WEB container), connect to the database in the WEB Container, and retrieve it from the database After a series of operations such as data, the display content of the page is dynamically assembled. After the display content of the page is assembled, all the displayed content is delivered to the WEB server, and then the content is sent back to the client browser through the WEB server for analysis and execution.

1.6. Means for realizing dynamic WEB applications    There are many realizing means for
  dynamic WEB now, the more common ones are the following:

Microsoft ASP、ASP.NET
PHP
JAVA Servlet/JSP

2. WEB server
2.1 Introduction to WEB server
  1. Web server refers to a program that resides on a certain type of computer on the Internet, and is a program that can provide documents to the requesting browser. When a web browser (client) connects to the server and requests a file, the server will process the request and feed the file back to the browser. The attached information will tell the browser how to view the file (that is, the file type).
The life cycle of container management components
  2. The server is a passive program: the server will respond only when a browser running on other computers on the Internet makes a request.

3. Build a JavaWeb application development environment-Tomcat server
3.1. Question: Why do we have to install a WEB server first when learning web development?
  1. No matter what web resource wants to be accessed by a remote computer, there must be a corresponding network communication program. When a user visits, this network communication program reads the web resource data and sends the data to the visitor.
  2. WEB server is such a program, which is used to complete the underlying network communication. Using these servers, We application developers only need to pay attention to how web resources are written, and do not need to care how resources are sent to the client, which greatly reduces the developer's development workload.

The bin directory stores some executable files, such as startup and shutdown, conf stores configuration files, lib stores jar packages required by the server, logs are log files, temp stores zero-time files, webapps stores websites and projects, and the work directory is Tomcat working directory

Software Architecture Pattern (MVC)
Introduction to Javabean:
Javabean; Divided into two categories: entity bean, business bean

Entity Bean: Entity class, especially the attribute is private modification, and then provides the getset method. No business method is provided. An entity class generally corresponds to a table in the database.
Business Bean: Except entity beans, they are all business beans.
Common software architecture mode:
jsp + javaban (Mdell mode):
Features: high efficiency, logical confusion, suitable for small projects

JSP + Servlet + javabeen (ModelI mode, the predecessor of MVC mode)
jsp: data display (view)
Servlet: logic control (controller)
Javabean: business processing (model)

MVC design pattern: Model (model), View (view), Controller (controller)
Benefits: easy division of labor, suitable for large projects, easy to maintain and expand.
Insert picture description here

The main points of development using JSP + Servlet + javaben design pattern:
JSP only displays data. Try not to write small java scripts.
Servlet; encapsulation of user input data (request. getParamer () ), setting of business processing results (request. setAttribute() ); control the flow of the page (redirection, forwarding).
javaBean: do related business processing.

Guess you like

Origin blog.csdn.net/ssdssa/article/details/109686429