Javaweb Basic Knowledge points
HTTP protocol
1.http belongs to the Application layer protocol, located at the top of the TCP/IP protocol
HTTP is a stateless protocol, a short connection that closes after the response is finished
TCP/IP is a long connection
MIME type: The Web server can return many types, and the browser can open it by itself using the specified application
2. Request Agreement
The request protocol consists of 4 parts: request line, request header, message body, blank line (used to separate the request header and message body)
Request Line: HTTP method, requested Url,http version
Request method: Get, post, put, delete
Get, post most commonly used most basic, put and delete in style inside can use
Get: Find, information insensitive, browser display, visible.
The length of the Send is limited (Web server specified, browser is not limited)
Post: Add-on, information encryption.
For sensitive information, large quantities of data, uploading data.
The web just receives data, no matter what way it's sent.
3. Response Agreement
Status line, response header, blank line, message body.
The status line contains: HTTP version, response code, Response description
Status line:
1XX: Received, continue processing
2XX: Successful, accepted treatment of successful behavior
3XX: Redirect, will send two requests, cannot process, will tell who will deal with themselves in initiating the request
4XX: Client side error, request contains syntax error or request cannot be
5XX: Server error, (programmer error)
The 4.WEB server can receive requests and process responses.
Flaw: can only provide static Web content like the customer, such as JSP those can not handle
Workaround: Add a secondary application to the Web server, which is responsible for producing dynamic pages.
such as Apache Web server Software
Server-side Web programming: The process of creating dynamic server-side content on a Web server
Address the development of Dynamic Web pages:
Cgi--servlet--jsp--mvc
CGI: Each request will open a CGI process, severely restricting server resources.
Servlets and Web containers: One in Java to solve CGI problems
Servlet: A Java program running on the Web server side or application server, running in a Web container without the main () method
Web container: Responsible for managing and running Servlets
Communication support, lifecycle management, multithreading support, JSP support, security
A servlet is instantiated only once, and a single instance of multithreading
The same type of request will only correspond to one servlet class
JSP: It's a servlet,html+java.
Common Web containers: Tomcat,jboss
Tomcat is also a product of Apache and a small Web server that can run out of Apache,
HTTP request and Response delivery process: Client request/Response Web server request/Response Web container per servlet1,2,
Java Web application consists of:
Configuration files,
static files and JSPs (for page display),
class files and Packages
Web pages (static HTML and dynamic JSP, placed in the root directory of the Web application, can also be placed in a subdirectory such as jsp,html)
Servlet,javabean and other class files are placed in the Web-inf/classes directory
Tags are placed in the Web-inf directory, multiple profiles the murder was in the TLD directory.
Each Web application should have a Web-inf directory, the. xml file, the classes directory
5. Browser review element features:
element: Look at elements, various CSS, etc.
NetWork: Can look at the request
Console: Control console, error messages, etc.
6.TOMCAT directory structure:
Bin: Start and close server script files
Conf: configuration information, such as service port number
Lab
Logs: Log
Temp: Temp File
WebApps: Write your own program after the deployment of things (external display)
Work:jsp page-Compiled class file
The most useful at this stage: conf,webaps
7. Relationships of classes and classes:
1. Generalization (inheritance) is-a
The arrow points to the parent class-
2. Implement the arrows to refer to the interface, the arrow vertical line curve--
3. Association: Owned and owned, member variable 1→n
4. Aggregation: The relationship between the whole and the part, can exist separately-◇
5. Combination: Whole and part, part cannot exist alone
6. Dependency: Use and be used (method call, etc.)------>
8.Servlet life cycle: Initialize, service, destroy
Initialization and destruction are usually performed only once, and the service can execute multiple times
Javaweb Basic Knowledge points