Servlet Technology 3_How to locate the URL address in the Servlet program to access

Client (browser) input:

http://localhost:8080/06_servlet/hello

Among them:
http:// means http protocol

localhost is the server ip

:8080 is the server port number

/06_servlet is the project path

/hello is the resource path

Server hardware computer ip address (ip is unique):

  1. Because the ip address is unique, you can locate the server ip. At this time, there will be a Tomcat server listening on port 8080 (locate the server by the ip address, and locate the Tomcat by the port number)

  2. There are many projects under the webapps folder, and the project path is used to determine which project to access

  3. After arriving in the project, which resource to access is determined by the resource path (search in the web.xml configuration file), through the resource path /hello, find the url-pattern in servlet-mapping, and then find the servlet-name in servlet-mapping, Find the servlet-name in the corresponding servlet tag to get the full class name in the servlet-class in the servlet tag; after finding the class based on the full list name, execute the function code in the service method

Guess you like

Origin blog.csdn.net/weixin_45024585/article/details/108855322