Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”

This article also participated in the “Digitalstar Project” to win a creative gift package and creative incentive money

👨🎓 author: Java Academic Conference

🏦 Storage: Github, Gitee

✏️ blogs: CSDN, Nuggets, InfoQ, Cloud + Community

💌 public account: Java Academic Party

🚫 special statement: the original is not easy, shall not be reproduced or copied without authorization, if you need to reproduce can contact xiaobian authorization.

🙏 Copyright notice: part of the text or pictures in the article come from the Internet and Baidu Encyclopedia, if there is infringement, please contact xiaobian as soon as possible. Wechat search public Java academic party contact xiaobian.

☠️ Who is not injured, while learning to be strong.

👋 Hello! I’m your old friend, the Java Academic Party, and I’ve been researching the roots of 23 design patterns: The Seven Design Principles. For everyone to complete a note, not very complete, but for the new contact with design patterns for small partners should be enough, can be used in an emergency. Hey hey, words do not say, next for everyone to tell about in detail.

1. The JavaWeb concept

  • JavaWeb refers to all programs written in the Java language that can be accessed through a browser. It is called JavaWeb.
  • JavaWeb is developed based on requests and responses.

2. What is a request

A Request is a Request sent by a client to a server.

3. What is a response

The Response is a value: The server sends back data to the client, which is called a Response.

4. Relationship between request and response

Requests and responses come in pairs, and there is a request and there is a response.

5. Classification of Web resources

Web resources are divided into static resources and dynamic resources according to different technologies and effects.

  • Static resources: HTML, CSS, JS, TXT, MP4 video, JPG images.
  • Dynamic resources: JSP pages, Serviet program.

6. Common Web servers

7. Mapping between Tomact server and Servlet versions

8. Tomcat is introduced

  • Tomcat is a core project of the Apache Software Foundation’s Jakarta project, developed by Apache, Sun, and other companies and individuals. With Sun’s involvement and support, the latest Servlet and JSP specifications are always present in Tomcat, and Tomcat 5 supports the latest Servlet 2.4 and JSP 2.0 specifications. Because of its advanced technology, stable performance, and free, Tomcat is deeply loved by Java enthusiasts and recognized by some software developers, and has become a popular Web application server.

8. Introduction to the Tomcat software directory

  • Bin stores executable programs of the Tomcat server
  • Conf is used to store configuration files of the Tomcat server
  • Lib is used to store the jar package of the Tomcat server (jar package: the specification of javaEE implementation, j stores the ava class)
  • Logs are used to store logs generated when the Tomcat server is running.
  • Temp is used to store temporary data generated during Tomcat running and will be released after the project is complete.
  • Webapps are dedicated to hosting deployed Web projects. (Inside a directory and a project)
  • Work is the directory where Tomcat works. It is used to store the source code for JSP translation into servlets at Tomcat runtime, and the directory for Session passivation (object serialization and deserialization). Compile a JSP file to a Java file, edit it to a class file, and create an object to call methods in the object.

9. How to start the Tomcat server

  • Go to the startup.bat file in the bin directory of the Tomcat directory and double-click it to start the Tomcat server.

  • How do I test that the Tomcat server started successfully?

  • Open your browser and enter the following address in the browser address bar (to find the address of your computer) :

  • Port 8080 is required because the protocol and port number of the browser to access are set in the server. XML file in the conf (configuration file) directory of Tomcat7

    • Port =”8080″ protocol=”HTTP/1.1″
    • Define a SSL HTTP/1.1 Connector on port 8443
      • http://localhost:8080
      • http://127.0.0.1:8080
      • http://own notebook real IP :8080

      The startup is successful if the following information is displayed:

10. Common startup failures

  • Double-click the startup.bat file, and a small black window will flash by.
  • In most cases, the JAVA_HOME environment variable is not configured.

11. The JVAV_HOME configuration is incorrect

  • JAVA_HOME must be in all uppercase letters
  • JAVA_HOME must contain an underscore, not a minus sign
  • You only need to configure the JAVA_HOME directory to the JDK installation directory. You do not need to bring the bin directory.

12. Another way to start the Tomcat server

  1. Open command line
  2. CD to your Tomcat bin directory
  3. Run catalina run

13. Stop the Tomcat server

  1. Click the Tomcat close button
  2. Set the Tomcat window to the current window and press Ctrl + C
  3. To stop the Tomcat server, double-click shutdown.bat in the bin directory of Tomcat.

14. How do I change the Tomcat port number

  • The default mysql port number is 3306
  • The default Tomcat port number is 8080
  • The default HTTP port is 80 www.baidu.com:80

Go to the conf directory in the Tomcat directory and sever. XML to the Connector tag

Change 8080 in port to the port number you want.

15. How do I deploy the Web project to Tomcat

  1. In the first deployment mode, you only need to copy the web project directory to the Tomcat Webapps directory.

    • Create a Test project in the Webapps directory

    • Put the submission form you made this morning under the Test folder

    • How to access web projects under Tomcat.

      At this time, enter http://localhost:8080 in the browser address bar to indicate that the query path is in the Webapps directory under the Tomcat directory.

      At this time to access the Test project (i.e., the Test folder), directly after the address and the file name http://localhost:8080/Test/ key: form validation. HTML

  2. In the second deployment mode, go to the D:\Tomcat7\conf\Catalina\localhost directory of Tomcat and create the configuration file in this directory

    Here is the configuration file format

16. Projects and resources accessed by default

  • When we sub ah browser address bar enter access address as follows:

    http://ip:port/ If there is no project name, the ROOT project is accessed by default.

  • When we enter the following address in the browser address bar:

    http://ip:port/ Project name/No resource name, default access to the index.html page.

17.IDEA integrates Tomcat server

  1. Locate the application server under Build, Execute, and deploy in the Settings of IDEA
  2. Click the + sign at the top, select Tomcat server, and find the location of Tomcat software on your computer in the Tomcat home directory of the pop-up dialog box.
  3. After the Tomcat home directory is filled in, the Tomcat base directory below fills in itself and displays the version number of Tomcat in the middle
  4. The next time you create a module, the application server column can select the Tomcat file you just configured

18. How to create dynamic Web projects

  1. Create a new module: first the project, then the module selects Java Enterprise, select the application server, and select the Tomcat version file you just configured
  2. Select what type of module to create: select the #Web module to create.

——-💘 after watching the big guys can pay attention to the xiaobian, will always update the small skills, free to share with you!! 💝 — — — — —