J2EE Learning (2) -- He Zhe container [Liang Ge learning notes], he weige
For Java programs, the JVM (Java Virtual Machine) is its operating system ,. java rewrite. class program case ,. for JVM, class is its writable line. Your Java program basically recognizes only one operating system, that is, JVM.
When you start to write your Servlet/JSP program, you must start with the concept of Container, the container name is also used in Collection objects such as List and Set, that is, the Collection objects used to hold and store objects. However, for the producer Servlet/JSP, the concept of containers is more generic. In terms of basic functions, containers do not possess objects, the lifecycle of an object is also linked to the related services.
On the specific aspect, a container is actually a Java program running on the JVM. Different types of containers may have different jobs, if the Web Container run by Servlet/JSP is also a Java program, think about it. The textual differences of HTTP are fixed, how to change to Java objects (such as HttpServletRequest and HttpServletResponse) available in your Servlet/JSP is actually the container for you to analyze and analyze.
On the abstract plane, you can refer the Web container to the Servlet/JSP running server of your pipeline. Yes! Just as Java programs recognize the JVM operating system, Servlet/JSP programs also recognize the Web server concept of Web containers on the abstract plane, as long as the Servlet/JSP in your pipeline conforms to the Web container standards, your Servlet/JSP can run on Web containers made by different vendors, you don't have to worry about accessing the Real Web server.
However, in reality, there is still a Web server, so back to the reality, the Web container is a Java application, you can manage the lifecycle of Servlet objects as part of a Web server program, and provide network services based on HTTP requests and responses.
If Tomcat is used as an example, the role location of the container can be expressed as follows:
Just as the JVM refers to the Java program and the actual operating system, the Web container is between the actual Web server and Servlet, just as you have created a Java program, you must understand how the JVM/JRE interacts with your application, the producer Servlet/JSP must also know how the container interacts with your Servlet/JSP, how to manage Servlet and other facts (JSP is also followed by logging, logging, and logging as Servlet. In the container world, the actual response request and response is Servlet ).
A basic example of request/response is:
The Web container must be understood by the ingress Servet/JSP. In the Java EE region, no matter which technology is used, it is related to the container information, servlet/JSP need to understand Web containers, EJB needs to understand EJB containers, and application client needs to understand application client containers, even when there is a small Applet, we also need to know the features of an Applet container.
The following example is a container Excerpt from the Java EE 6 APIs file in Java EE 6 Tutorial:
For Servlet 3.0/JSP 2.2 in Java EE 6, you can use Tomcat 7 or Glassfish v3 as the actual container, in the Web Container section of Tomcat 7 injection, Glassfish v3 is a complete application server, and also includes the functions of Web containers (of course, there are also other vendors ). See: http://openhome.cc/Gossip/ServletJSP/