The Tomcat Java tutorial to get started combing point

Jrebel published a 2020 Java ecosystem report, survey results showed that 61% of major application server developers who are still using Tomcat. Many beginners who do not know how Java entry Tomcat, Java learning the next tutorial, Xiao Bian gave you to do a simple sort of knowledge.

What is Tomcat
Tomcat is a Servlet container Apache developed, implemented support for Servlet and JSP, and offers some unique features as Web servers, such as Tomcat management and control platform, security domain management, and Tomcat valve. Tomcat includes a configuration management tool that can be configured by editing XML configuration file format.

Tomcat important directory
/ bin - Tomcat script storage directory (such as startup, shutdown script). * .sh for Unix file system; * .bat file for Windows systems.
/ conf - Tomcat configuration files.
/ logs - Tomcat default log directory.
/ webapps - webapp running directory.

Tomcat common assembly
1. The server (server)
instance, usually contains only one instance of a JVM, in general, a plurality of physical server can start JVM, to initiate a plurality of instances, but generally do not do so.
2. Service (service)
a service component usually contains a one engine and this engine associated with one or more linked server.
3. Connector (Connectors)
a plurality of connectors can be configured engine, but the port must not conflict each connector. At the same time, Tomcat and also supports AJP JSERV JK2 connector, which allows Apache reverse proxy to a very efficient transmission protocol backend server.
4. The engine
may receive a user's own http request, and constructs the response packet, and can handle the entire suite of programs within the java.
5. Host
6. context
7. The valve can be filtered can do the access control.
8. logger
9. art (Realm), to implement user authentication and authorization.

Any Tomcat instance is a server, and an internal server in order to be able to parse the JSP page compiler escape serlet program, rely on their engines to achieve. JSP code is executed on the real meaning of the vessel engine, Tomcat is used to describe the class of these components. Meanwhile, in order to accept the user's request, based on the needs of the connector socket assembly, the so-called listening program, to take over the user's request, is referred to as a connector. An internal server can run entirely N engines, nothing more than to run multiple virtual machines only.

Tomcat installation
view the file:

cat /usr/local/tomcat/conf/server.xml

Listener as a listener, commonly implemented inside tomcat communication, the communication can be accomplished between components
<ServerPort = "8005" = the shutdown "the SHUTDOWN">
<Listener className = "org.apache.catalina.core.AprLifecycleListener" the SSLEngine = "on" />



Global name resources to facilitate global references, so after its name from the finish can easily be called

<Resource name = "UserDatabase" auth = "Container"
of the type = "org.apache.catalina.UserDatabase"
the Description = "the User databasethat CAN BE Updated saved and "
Factory's =" org.apache.catalina.users.MemoryUserDatabaseFactory "
pathname =" conf / Tomcat-users.xml "/> # that calls for user authentication tomcat-user.xml profile

Service class component configuration information, the connector linked to the engine
<Servicename = "Catalina">
<Connector Port = "8080" Protocol = "the HTTP / 1.1" # where monitor port, and a protocol version
connectionTimeout = "20000" # connection timeout milliseconds
redirectPort = "8443" /> # redirection can be done when necessary, defined in 8443
<Connector port = "8443" = protocol "the HTTP / 1.1" SSLEnabled = "to true" listening port # 8443, the agreement HTTP1.1
maxThreads = "150" scheme = "HTTPS" secure = "to true" # maximum thread, protocol version, security
clientAuth = "false" sslProtocol = " TLS" /> # does not validate the client ssl protocol is used tls

<Connector port=“8009” protocol="AJP/1.3"redirectPort=“8443” />

# Engine named Catalina
<RealmclassName = "org.apache.catalina.realm.LockOutRealm">
<RealmclassName = "org.apache.catalina.realm.UserDatabaseRealm"
the resourceName = "UserDatabase" />
<the Host name = "localhost" the appBase = "webapps" position # application file is stored, the relative path
unpackWARs = "true" autoDeploy = " true"> # If the war file format, whether decompression, whether automatic deployment

     #定义阀门,java中类的记录方式,当前所处域名反过来写的记录方式        

<ValveclassName = "org.apache.catalina.valves.AccessLogValve" Directory = "logs"
prefix = "localhost_access_log." Suffix =. "TXT" log # name suffix represents stamp
pattern = "% h% l% u% t "% r"% s% b "/> # access log format



Published 843 original articles · won praise 108 · views 80000 +

Guess you like

Origin blog.csdn.net/qf2019/article/details/104750307