Web Directory
War file
The war file is just a snapshot of the Web application architecture, using a more portable form of compression.
When a war file is created, it compresses the entire Web application structure (removing the Web application context directory, or removing the first-level directory above web-inf), given a. war extension.
How does a container know the name/context of a Web application? In Tomcat, the war file name is!
In a war file, it can be meta-inf/manifest. What is the difference between declaring a library dependency in a MF file (and directly under Web-inf/lib)? Later in the article see).
The appearance of the deployed war file
Enables static content and JSPs to be accessed directly
The content in Meta-inf or web-inf is not directly accessible, otherwise a 404 error is generated.
Meta-inf What's the use?
If a class is deployed in a Web application using a jar file in the web-inf/classes directory or Web-inf/lib, these classes are automatically available;
However, if the application relies on a particular version of the library, and if the container cannot provide the libraries, the application cannot be successfully deployed, so you can tell the container which optional libraries must be accessed in the MANIFEST.MF file. (It's much better to not deploy an app than to find it when you request it!) )
Remember that the container looks for the classes in the Web-inf/classes directory before looking at the jar files in Web-inf/lib.
Servlet Mappings in DD
Three types of Url-pattern elements
Exact matches, directory matches, and extension matches:
There is an important rule for a servlet mapping
- The container finds the match in the order in which the next page is displayed. In other words, find an exact match first. If an exact match cannot be found. Find the directory match again. If the directory match is not found, the lookup extension matches.
- If a request matches multiple directory Url-pattern, the container chooses the longest distance.
Configure the Welcome file in DD
To configure the Welcome-file-list element, the container starts with the first welcome file of the list:
Configuring the error page in DD
- Declaring a generic error page
This applies to all resources in the Web app, not just the JSP
- A more explicit exception error declaration
- Declaring error page based on HTTP status code
Configuring servlet initialization in DD
The servlet is initialized by default when the first request arrives, and you can set the Load-on-startup element if you want to load the servlet when the deployment or server restarts.
If multiple elements are configured, the values are loaded from small to large.
JSP Document: XML-compatible JSP page
Finally, check out some of the most recently unused markings.
- The DD tag associated with the EJB
JNDI env-entry DD Tag
Mime-mapping DD Mark
"Head First Servlets & JSP" -11-web application Deployment