1.Servlet Introduction
A servlet is a short term for a Java servlet, called a small service or service connector, a server-side program written in Java.
The main function is to interactively browse and modify data to generate dynamic Web content
Applet running on the server: MVC (Model view Controller)
The servlet runs in a Java-enabled application server. In reality, a servlet can respond to any type of request, but
In most cases the servlet is used only to extend the HTTP protocol-based Web server
Servlet: can accept any request from the client
Servlet programming requires the use of classes and interfaces under the Javax.servlet and javax.dervlet.http two packages in all interfaces
The Javax.servlet.servlet interface is the most important. All servlet programs must implement the interface or inherit the class that implements the interface.
Basic use of 2.Servlet
1. Create the package in SRC
2. Select the package you just created, right-click-->new-->servlet
3. Find Doge write "Hello word"
1. Publish right-click-->run as-->run on Server
2. Browser input URL access: http://localhost:8080/project name/helloservlet
3. Common Mistakes
4.HTTP protocol
4.1 What is the HTTP protocol
Hypertext Transfer Protocol (Http,hypertext Transfer Protocol) is one of the most widely used network protocols on the Internet, and is a stateless, application-level protocol based on request and response mode, which is often based on TCP connection mode.
Features of 4.2.HTTP
4.3HTTP process of request (interview)
Three ways to create 5.Servlet
The first form of servlet creation: inheriting HttpServlet
The second way that Servlets are created: Implementing an interface Servlet
The third way to create a servlet: Inherit the Genericservlet class
Two ways to configure 6.Servlet
6.1 Annotation Configuration Servlet3.0 after
Life cycle of 7.Servlet
8. Get the requested parameters
9.Servlet path processing and characterization (******)
9.1 What is redirection
Redirection is a variety of ways to redirect various network requests to another location and the following to describe the forwarding is the way to jump.
Features of redirection:
The difference between redirection and forwarding (interview):
9.1.1 Implementation Redirection (Response.sendredirect)
9.2 Request Forwarding
Servlet supports request forwarding in addition to redirection support
Principle: I like you borrow money, you have no money, and you did not reply to me, silently to your friend's loan to me.
Characteristics:
9.2.1 Implementing Request Forwarding (Request.getrequestdispacher)
9.3 Another way to forward refresh
10.ServletContext
10.1 What is ServletContext
The servlet context is also called: ServletContext.
When the Web server starts, a shared storage area is created for each Web application (each directory under WebApps is an application)
ServletContext is also called a "common area", in which all servlets and JSPs can share the same area in the same Web application.
ServletContext is created when the Web server is started and destroyed when the server shuts down
When the container starts, it creates a unique object for each Web application that conforms to the ServletContext interface, which is generally referred to as the servlet context.
The functions and characteristics of 10.2 servlet in context
One . servlet thread safety issue 11.1 thread safety issues
11.2 How to ensure thread security issues
Servlet (Introduction, request parameters, page jump, life cycle, creation, configuration, ServletContext, threads)