Tomcat containers and Web application related notes __web related

Source: Internet
Author: User
1, after the installation of Tomcat a few directories, respectively:
() bin ———————— start and close Tomcat's script file () conf--the various configuration files that hold Tomcat servers (including Tomcat's various startup parameters, the most important Servlet.xml) () lib-- The Support Jar Pack () that holds the Tomcat server logs--the log file () for Tomcat () temp--storage of the temporary files () generated by the Tomcat runtime () webapps--web the directory where the application resides (), which is the repository of Web resources that provide access to the outside world () work Working directory for--tomcat

2. Configure Web Applications in Tomcat: (add context in Server.xml configuration file) $CATALINA _base represents the Tomcat home directory () in Server.xml configuration file </Host> Tag before: <centext path= "map path" docbase= "Web Application Folder"/> path Specifies the mapping path that is used by the user docBase the specified folder is the home directory where the Web application is developed. () URL Resolution: http://localhost:8080/Mapping Path/specific Web page () but this method is configured every time that Tomcat restarts.

3. Configure Web applications without restarting Tomcat: (new "*.xml" file in $catalina_base/conf/[enginename]/[hostname]/, then configure context in file) () jump into $catalina_  base/conf/[enginename]/[hostname]/directory such as: C:\Tomcat\apache-tomcat-6.0.41\conf\Catalina\localhost () new "*.xml" File: A.xml file —————— A is the context path, that is, the external access directory, so the file does not need to add: the Path parameter () file directly add Tags: <centext docbase= "Web Application Folder"/>-- <centext docbase= "F:\javaWeb\project1"/> At this time the outside access path: http://localhost:8080/aaa/... A specific Web page
() If the established "*.xml" file name is "Aaa#bbb#ccc.xml", then the external access path is: http://localhost:8080/aaa/bbb/ccc/... A specific Web page

4, Tomcat has a default application. The http://localhost:8080/jumps out when clicked. () You can manually specify the default Web application so that http://localhost:8080/represents the specified application. The specific approach is to change the established "*.xml" file file name to ROOT, that is, the file is "Root.xml" at this time the external can directly enter the http://localhost:8080/specific Web page to access. () The Server.xml configuration Web application can also be specified as the default: <context path= "docbase=" The path to Web application/> —————— path is empty.

5, the composition of the Web application structure: Different types of files are strictly placed in different places, or may result in the application can not access or the Web server to start an error. The specific directory structure should be: () HTML, CSS, JS files, etc. in the directory where the Web application is located in the root directory. ———— The files Here are directories that can be accessed directly from outside () web-inf directories —————— Java classes, jar packages, and WEB application configuration files, which are not directly accessible to the outside world. Called by the Web server. Classes Directory —————— put Java class lib directory ———————— Java class to run the required jar package Web.xml files —————— to configure and manage Web resources, very important files.


6, a page configuration into the home: Web.xml file. The format is similar here, and headers and tails can be copied from Tomcat's Web.xml file.     (1) Only change: Just change the specified page can be —————— here do not need to restart. <welcome-file-list> <welcome-file> Specify page </welcome-file> </welcome-file-list>

7, configure Tomcat's port number is 80: Change server.xml file <connector port= "8080" protocol= "http/1.1" connectiontimeout= "20000 "redirectport=" 8443 "/> Changed to <connector port=" "protocol=" http/1.1 "Connectiont imeout= "20000" redirectport= "8443"/> At this time the address bar input: http://localhost:8080/change to http://localhost:80/or direct http:/ /localhost/on the line.
() The default port number for the HTTP protocol is 80.

8. If a Web application has already been configured with the home page, it is also set to the default application, and the port number is configured to 80. The Address bar input: http://localhost/is the home page.

9, Web.xml files must be placed in the Web-inf directory. He is a Web application configuration file. () When developing a Web application, you configure it in this file as long as you configure the Web resources for the Web application. () A modified file can be used to configure: A Web resource is configured for the Web page to map a servlet program to a URL address for Web application configuration listeners to configure filters for Web applications ...

10, Tomcat role: () container to the Web server and servlet communication between the bridge. With Tomcat,servlet, you don't have to think about the Web server, focus on the business logic. () Tomcat controls the life and death of the servlet. Responsible for loading classes, instantiating and initializing the servlet, invoking the Servlet method, and allowing the servlet instance to be garbage collected ....


11. Container Processing Request process: ———— user sends an HTTP request to a servlet instead of a static page (such as submitting a form) ———— the Web server cannot handle the dynamic request, handing the request to Tomcat. (The Web server can only read user requests, find the corresponding static page and go back accordingly.) For dynamic requests, the Web server invokes the corresponding Web application "such as Tomcat container" to process the request, the Web application processes the result "HTML" to the Web server, the Web server gets the results and sends it to the customer ———— Tomcat read request, Know that you want to give a servlet a request and response object, locate the specified servlet based on the URL of the request, create an allocation thread for the request, and give the request and response object to the servlet for processing. The ———— container invokes the servlet's service () method, which invokes the doget () or Dopost () method based on different requests. The Doget () method generates a dynamic page, writes the page to the response object, and then ends the thread. ———— Tomcat translates the response into an HTTP response to the Web server and deletes the request and response object. ———— the Web server to respond to customers.

12. How Tomcat finds the servlet: the URL that the user requests is mapped to a specific servlet on the server in some way. URLs and servlet mappings can take a number of ways, and this mapping is configured in Tomcat. () a servlet has 3 names: the name of the public URL of the deployment name given to the deployment servlet when the file pathname is deployed, by which time the customer knows the names to be written in HTML.

13, IE browser to send a request when the first step is not to DNS domain name resolution server to resolve the domain name, but first to see if the "c:\windows\System32\drivers\etc\hosts" file has changed the name Mapping. () The Hosts file can be configured with a name mapped to an IP address that can be configured with multiple such mappings.

14, configure the virtual host--Set up a website (with domain name): () There are two ways: Windows system configuration, the DNS server to request domain names. () Configure name mappings in the Windows System Ip:㈠ add mappings in the "c:\windows\System32\drivers\etc\hosts" file, such as: 10.50.15.14 www.xiaoyang.com ㈡ add <Host></Host> tag to tomcat server.xml
15, do not know a domain name corresponding to the IP address can be ping domain name to obtain IP address ping www.baidu.com

16, Tomcat management platform ———— use the browser to enter —————— remote management needs ———— user name and password to enter. () Enter the host Help document ———— select "Tomcat Manager" in the "Administration" option ———— enter a username and password to enter () Configure users, passwords, and roles: Conf/tomcat-users.xml files () the role and user name of the file have been commented, you can remove the annotation, or you can manually add roles and user names. <tomcat-users> <role rolename= "Tomcat"/> ———————————— if you want administrator privileges: rolename= "Manager"--look at the next line <role Rolename= "Manager"/> <role rolename= "role1"/> <user username= "Tomcat" password= "Tomcat" roles= "Tomcat"/&   Gt <user username= "Both" password= "Tomcat" roles= "Tomcat,role1"/> ———————— multiple roles are comma-delimited <user username= "Role1" Password= "Tomcat" roles= "Role1"/> </tomcat-users>
() can be managed in the platform management due to applications, including deletions.

17. Configure HTTPS connector:

18. HTTP protocol: request, response

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.