Tomcat topic One: The Java base of Tomcat

Source: Internet
Author: User
Tags posix

Tomcat Basics of Java

Dear friends, starting from this article, there will be a succession of seven articles to the Tomcat this software, or a Web container to do a discussion. Or the same style, I will not intentionally typesetting, the article with the professional paper, just think of where to write, try to write what they know.

Java is introduced because the language that Tomcat targets is the Java language, which is an explanatory container for Java programs. Although Tomcat itself implements a Web container that not only interprets Java programs but also interprets the HTML language, it is customary in a production environment to build Java application servers with Tomcat. As I understand it, Tomcat just provides a web framework for Java applications, such as a web interface to a front-end HTTP protocol, a servlet container, a connector, a virtual machine host, and a JVM virtual machine that Java applications have to mention, which is not a Tomcat feature. , but the functionality provided by the Java system. Therefore, it is necessary to have a general understanding of the Java programming language in order to fully understand Tomcat.

Evolution of the program

Java is a cross-platform programming language, where does this really manifest itself? What kind of mechanism makes it possible to implement cross-platform applications.

from the evolution of the program, early in the computer was just born, at that time the programming language is machine language, the so-called machine language is a bunch of binary 01 code, because of learning difficulties, programming difficult, so later appeared the assembly language, Assembly language has improved to a certain extent, but because it is very close to machine language, because it also makes many programmers look at the halt. In order to solve this situation, there appeared high-level language, which is now used in the programming language, such as: C,c++,php,java.

Since so many high-level languages have been produced, programmers are becoming more and more adept, but there are still many problems with the operating system architecture. Here's what we need to know about the operating system, the Linux system I'm targeting (which is basically the same for other systems).

Linux may know that in the Linux system, there are two important workspaces, one is the user space, and the other is the kernel space. User space through the shell and the upper layer of users to interact with the core space to manage the various environments of the computer, it is particularly known that the kernel manages all the hardware functions of the computer. All user-space programs are not allowed to interact directly with the hardware, the kernel must interact with the hardware, and the kernel interacts with the hardware through a single functional system call to deal with the hardware and control the operation of the hardware.

   

with the API, greatly reduce the work of programmers, but for the program, different systems of different APIs, resulting in the development of programs on different systems can not be translated on another operating system , in order to run this distinction, The posix:portableoperating system is produced, so long as this specification is followed, programs developed on one operating system can be compiled on any POSIX-compliant system, where the application realizes cross-platform compilation. However, it is not possible to run across platforms. Because although the different API is run-in, but different systems between the ABI is different, so-called abi:application binary interface, the application of binary interface. Following the Posifx interface, although it is possible to compile on any system, a program compiled on one operating system is not able to run directly on another operating system. Because the binary interfaces of the two operating systems are different. For example, Linux is based on. So, and Windows is based on. dll. To achieve cross-platform operation, unless a machine is created

The difference between the in-running ABI. At this point Java appears, Java not only running into the API also run into the ABI, which is mainly attributed to the Java Virtual Machine JVM. The JVM virtual machine mechanism is actually divided into two pieces, one is directly related to the upper program language JVM virtual machine, and the lower system directly related to the JVM mechanism, through the JVM of this two-layer mechanism to run the different ABI, making a Java program compiled on a system, It is easy to run on different operating systems.

As a result, a Java program compiles and runs everywhere. But remember that Java runs on a Java-based virtual machine. In this case, the Java language has been introduced, and the above-mentioned heap of abstract things is actually to explain why the Java language can run across platforms.

JAVA Technical Essentials

Java the application has four independent but related components

1.java Programming Languages

2.java API : Java application programming interface, sometimes considered to be a library that encapsulates some column functions

3.java class : Java class file

4.jvm:java Virtual machine , the Java Virtual machine

Related processes:

Java programming language combined with JAVAAPI, Java program to achieve a variety of functions, Java program through the Java compiler (in fact, Javac) compiled into a number of columns of Java class files, Java class files are placed in the JVM run, implementation of program functions, Only Java class files can be compiled to run in the JVM.

Java programs are usually files that end in. Java

Java class files are usually files that end with a. Class (the equivalent of a byte code)

Since the Java program must be compiled into a. class file before it can be executed in the JVM, what is the implementation of the JVM? (Note: Java programs run in the JVM, so the process of compiling is also implemented in the JVM)

JVM How to Implement program compilation:

1. a one-time interpreter, which interprets bytecode and executes (that is, to interpret. class files), explains the process of converting bytecode into a true binary. Be aware that every execution requires an explanation .

2. the Instant compiler (Just-in-time complier), which interprets bytecode for the first time, interprets the binary code as interpreted, thus requiring more memory to cache the interpreted result. This can result in a large amount of memory, which can cause memory overflow if the JVM virtual machine memory is not enough

3. Adaptive Compilers: Automatically caches the binary code that performs the masking comparison, not the full cache, thus combining 1 and 22 methods to achieve a compromise. 28 rules, cache about 20% of the code, improve the speed of about 80%;

JVM: There are many kinds of JVMs

Sun the company's own jvm:hotspot JVM

also divided into two kinds;

Jre:java Operating Environment

JDK : Java Development environment

JDK includes JRE, but not only JRE, but also a lot of development features, etc.

jvm:openjdk in the open source world

Open Source implementation of development + run

JRE : Java runtime Environment, in fact, the implementation of one of the simplest JVM virtual machines is the JRE, to run Java programs you must install the JRE. However, the JRE does not tightly implement the functionality of the JVM, but also provides some functional APIs

JDK : JDK features more, basically contains the Java program source code, API,JVM and other functions

JAVA Java technology can be divided into three categories depending on its application domain:

JAVA Se:java Standard Edition class library for small and midsize businesses

JAVA EE : JAVA Enterprise Edition large Business

JAVA ME : Mobileedtion,java mobile version, used to develop mobile programs (less used)

In addition, the JVM virtual machine also implements a lot of garbage collection mechanism, these things are not chat, not programmers, not clear AH.

JAVA The Dynamic Web site implemented

Client Dynamic Web site:

applet: Small Program

Java-developed applets applet embedded in the HTML page, the client accesses the HTML page, the applet applets are downloaded to the local, and then run in the local JRE environment, you must ensure that the client installed the JRE runtime environment

Server Dynamic Web site:

CGI : Commongateway Interface

generate a static page on the server side and return it directly to the client without running dynamic content on the client using the JRE

Servlet : Java implementation of CGI, added to the HTTP protocol processing ability, can recognize the HTML document regardless of the implementation method above, static pages are managed by the JAVA source program, once changed, it must be compiled into bytecode to run in the JVM virtual machine

JSP : Java serverpage

is based on a special class on the servlet, you can embed the Java program in the HTML document, so that the HTML document does not need to be processed by the Java source program. The JSP implements a Java program embedded in the HTML page as a label.

JSP when the program executes, the JSP page must first be converted to a servlet using Jasper and then compiled into bytecode in the Java compiler to run in the JVM virtual machine

JSP performance and stability is much better than PHP programs, so in large applications and business occasions, the basic use of JSP programs.

    > So far, there's probably a lot of confusion about what it says about so many languages, and that Tomcat is actually working on pages that are written in that language. Here is a brief introduction to the relationship between each other. Java language is a programming language, the early Java language is a static language, in order to achieve Dynamic Web site, late application of the Applet,servlet technology, applet is a client-side technology, and Sevlet is executed on the server, the technology, However, both applets and servlet technologies are a class library in the Java language and are implemented in the Java language. The JSP language is a special class library based on the servlet technology, which can implement the Java language nested in the HTML page, when the user requests, when the request to the JSP page, the nested Java language will be compiled into a servlet, and then compiled into a byte code, Run in the JVM virtual machine, and then return the results and HTML page back to the client, using the JSP technique, the static page of HTML is no longer compiled with the Java program. Now, the Java implementation of Dynamic Web sites are JSP this technology, it can be said that JSP is not a real programming language, but a framework, the integration of the Java language and HTML pages. Therefore, although you may often see the. JSP end of the page, but nested inside the dynamic page is still the Java language, so that Tomcat processing Java program is also right. Second, it is important to note that this discussion of JSP and Java is from a programmatic point of view, rather than what is the execution process, JVM virtual machine and so on. For example, if you now write a JSP page, write a Java program, you may not want to run a JVM, but the first flash in the brain is the knowledge of JSP and Java programming, what kind of programming format, direct point to write JSP and Java source Program page is the same? I would like to use Java development of talent can say clearly the relationship here, we have unclear can and development communication, and when you ask the difference between JSP and Java, development will not tell you what the JVM is running and so on. Now you understand what I mean by that.

Well, the Java technology about Tomcat is just here, purely personal understanding. There is no point, can communicate.


This article from the "Life and death as the Dream Mo Sentimental" blog, please be sure to keep this source http://mingyang.blog.51cto.com/2807508/1577100

Tomcat topic One: The Java base of Tomcat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.