Introduction of three commonly used components of Java
This article introduces the knowledge of "introduction of the three commonly used components of Java". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
I. Servlet
Servlet is a dynamic resource used to process client requests, that is, when we type an address into the browser and enter to jump, the request will be sent to the corresponding Servlet for processing.
The specific processing process:
1. Receive request data: we all know that client requests are encapsulated into HttpServletRequest objects that contain request headers, parameters, and other information.
two。 Processing requests: usually we receive parameters in the service, doPost, or doGet methods and call the business layer (service) method to process the request
3. Response: after processing the request, we usually forward (forward) or redirect (redirect) to a page. Forwarding is a method in HttpServletRequest and redirection is a method in HttpServletResponse. There is a big difference between the two.
Filter (filter): similar to Servlet, it is used to intercept or release requests. (there are four ways to intercept (unfamiliar)) there are three ways to match:
Exact match, such as / foo.htm, will only match the URL of foo.htm
Path matching-for example, / foo/*, matches URL prefixed with foo
Suffix matching, such as * .htm, matches all UR with the suffix .htm
three。 Listener (listener): add a listener to the button. When you click this button, you will trigger a listening event and call the onClick method, which is essentially a method callback.
This is the end of the introduction of the three commonly used components of Java. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!