Detailed analysis of servlet addresses and servlet address Analysis
Path
Hypothesis;
Project name: day01
Demo.html
Forwarding
Request. getRequestDispatcherType ("path"). forward (request, response); // path =/demo.html
Redirection
Response. sendRedirect ("path"); // path =/day01/demo.html
Url in html
<Html>
<Head> <title>
<Body> <a href = 'path'> hyperlink </a> </body> // path =/day01/demo.html
</Html>
Submission address in the action of form
<Html>
<Head> <title>
<Body> <form action = "path"> </form> </body> // path =/day01/demo.html
</Html>
Summary:
Who is the target resource used?
1. the tomcat server/Represents the root directory of the current web Project ('root directory '). You can directly write the static resource name.
2. The Browser/Represents webapps, so the project name and static resource name must be added.
Note: the root directory of a web project refers to the project name. However, when the project is deployed on the tomcat server, it copies the project to webapps, the folders and files under webroot are directly copied to the project's underground. The structure of the webroot overwrite directory is as follows:
Project working directory
Local file directory (no webroot directory)
Load External Resources
See servletcontext and servletconfig.