Content and Structure
A WAR file may be digitally signed in the same way as a JAR file in order to allow others to determine what source the code came from.
There are special files and directories within a WAR file.
The /WEB-INF directory in the WAR file contains a file named web.xml which defines the structure of the web application. If the web application is only serving JSP files, the web.xml file is not strictly necessary. If the web application uses servlets, then the servlet container uses web.xml to ascertain to which servlet a URL request will be routed. web.xml is also used to define context variables which can be referenced within the servlets and it is used to define environmental dependencies which the deployer is expected to set up. An example of this is a dependency on a mail session used to send email. The servlet container is responsible for providing this service. Advantages of WAR files:
- easy development, testing and deployment
- the version of the deployed application is easily identified
- all J2EE containers support .WAR files
One disadvantage of web deployment using WAR files in very dynamic environments is that minor changes cannot be made during runtime. Any change whatsoever requires regenerating and redeploying the entire WAR file.
The following sample web.xml file demonstrates how a servlet is declared and associated.
The /WEB-INF/classes directory is on the ClassLoader's classpath. This is where .class files are loaded from when the web application is executing. Any JAR files placed in the /WEB-INF/lib directory will also be placed on the ClassLoader's classpath.
Read more about this topic: WAR File Format (Sun)
Famous quotes containing the words content and, content and/or structure:
“Know how to be content and you will never be disgraced; practice self-restraint and you will never be in danger.”
—Chinese proverb.
Laozi.
“I am content to live it all again,
And yet again, if it be life to pitch
Into the frog-spawn of a blind mans ditch.”
—William Butler Yeats (18651939)
“The philosopher believes that the value of his philosophy lies in its totality, in its structure: posterity discovers it in the stones with which he built and with which other structures are subsequently built that are frequently betterand so, in the fact that that structure can be demolished and yet still possess value as material.”
—Friedrich Nietzsche (18441900)