Lock screen interview questions will be brushed every day, and the interview questions will be updated every working day. The lock screen interview question app and applet are now online. The official website address is:https://www.demosoftware.cc/#/introductionPage。 It has included all the contents of the interview questions updated every day, as well as the features of unlocking the screen to review the interview questions, daily programming questions, e-mail push and so on. Let you take the lead in the interview and hang the interviewer! Next is today’s interview question:
====What is the default port of Tomcat and how to modify it?
Default port 8080
1) Find the conf folder under the Tomcat directory
2) Enter the conf folder and find the server.xml file
3) Open the server.xml file
4) Find the following information in the server.xml file
< connector connectiontimeout = “20000” port = “8080” protocol = “http / 1.1” redirectport = “8443” uriencoding = “UTF-8” / > port = “8080” change to the port you want
====What are the connector operation modes (optimized) of Tomcat?
Bio: traditional Java I / O operation, synchronous and blocking io. Maxthreads = “150” / / Tomcat uses threads to process each request received. This value represents the maximum number of threads that Tomcat can create. The default value is 200. It can be adjusted according to the period performance and memory size of the machine, generally 400-500. The maximum can be about 800. Minsparethreads = “25” — the number of threads created during Tomcat initialization. The default value is 4. If there are currently no idle threads and maxthreads are not exceeded, the number of idle threads created at one time. The number of threads created during Tomcat initialization is also set by this value. Maxsparethreads = “75” — once the created thread exceeds this value, Tomcat will close the socket thread that is no longer needed. The default value is 50. Once a thread is created that exceeds this value, Tomcat closes threads that are no longer needed. The number of threads can be roughly “number of people online at the same time”Number of user operations per secondSystem average operating time. Acceptcount = “100” — specifies the number of requests that can be put into the processing queue when all available threads for processing requests are used. Requests exceeding this number will not be processed. The default value is 10. If the number of currently available threads is 0, the request is placed in the processing queue. This value limits the size of the request queue. Requests exceeding this value will not be processed. Connectiontimeout = “20000” — network connection timeout, default value: 20000, unit: milliseconds. Setting to 0 means never timeout. This setting has hidden dangers. It can usually be set to 30000 milliseconds.
NiO: jdk1.4 supports synchronous blocking or synchronous non blocking io. Specifies that the NiO model is used to accept HTTP requests. Protocol = “org. Apache. Coyote. Http11. Http11nioprotocol” specifies that the NiO model is used to accept HTTP requests. The default is blockingio, which is configured as protocol = “http / 1.1” acceptorthreadcount = “2” the number of receiving threads when using NiO model
AIO (NiO. 2): JDK7 supports asynchronous non blocking io. APR: Tomcat will call the core dynamic link library of Apache HTTP server in the form of JNI to process file reading or network transmission operations, so as to greatly improve Tomcat’s processing performance of static files.
<Connector connectionTimeout=”20000″ port=”8000″ protocol=”HTTP/1.1″
<!– Protocol enables NiO mode, (NiO is used by default for tomcat8) (APR mode uses system level asynchronous IO) – >
<!– Minprocessors minimum number of idle connection threads — >
<!– Maxprocessors maximum number of connection threads — >
<!– The maximum number of connections allowed by acceptcount should be greater than or equal to maxprocessors — >
<!– If enablelookups is true, requst.getremotehost will perform DNS lookup and reverse resolve the domain corresponding to the IP
Name or hostname — >
<Connector port=”8080″ protocol=”org.apache.coyote.http11.Http11NioProtocol”
Maxhttpheadersize = “8192” the maximum of HTTP request header information. The part exceeding this length will not be processed. Generally 8K.
Uriencoding = “UTF-8” specifies the URL encoding format of the Tomcat container.
Disableuploadtimeout = “true” whether to use the timeout mechanism when uploading
Enablelookups = “false” — whether to reverse query the domain name. The default value is true. To improve processing power, it should be set to false
Compression = “on” turn on compression
Compressionminsize = “10240” enable compressed output content size, which is 2KB by default
Nocompressionuseragents = “GOZILLA, Traviata” compression is not enabled for the following browsers
Some resource types need to be compressed
====How many deployment modes does Tomcat have?
The first method: directly copy the web project file (generally the war package generated by copying) to the webapps directory of Tomcat.
The second: in the conf directory of the local tomcat, create a Catalina / localhost directory (pay attention to the case of the file name here), and then create an XML file under this directory. The name can’t be taken arbitrarily. It should be consistent with the name after the path. Here should be the test.xml file. Its specific contents are as follows:
<Context docBase=”D:\work\test\web” path=”/test” reloadable=”true”/>
Third: in the server.xml file under the conf directory in tomcat, add a context in the < host / > node, specifically:
<Context Path=”/test” Docbase=”C:\work\test\WebContent” Debug=”0″ Privileged=”True” Reloadable=”True”></Context>
====How does the Tomcat container create servlet class instances? What principle is used?
When the container starts, it will read the web.xml files in all web applications in the webapps directory, then parse the XML files and read the servlet registration information. Then, the servlet classes registered in each application are loaded and instantiated through reflection（ Sometimes, it is instantiated at the first request) add the loadonstartup parameter when registering the servlet. If it is a positive number, it will be instantiated at the beginning. When the web container starts, it will be instantiated in the order from small to large. The small positive integer will be instantiated first. If it is not written or negative, it will be instantiated for the first time.
More interview questions or learning resources can be obtained from my home page or comments