What is a WAR file? How can I use this efficiently in my Web applications, as I am using JSP, EJB, XML?
A J2EE application is a group of Web modules that collectively perform as a single entity. A Web Module is an entity consisting of one or more resources such as HTML files, Java class files, JSP files, XML files, etc. Web Modules are packaged in Web Archive (WAR) files. An EAR (Enterprise Archive) file is a JAR file encapsulating a J2EE application. In other words, EAR files contain EJB JAR files, WAR files, application resources, etc.
A Web application has a WEB-INF/lib directory in which utility classes, resource files and JAR files can be placed in order to be accessed by servlets and other classes running in the context of a servlet. The extension mechanism for JDK 1.3 allows .jar files to declare dependencies upon other .jar files using a "Class-Path:" attribute in the manifest file. The Class-Path: attribute consists of a list of relative URLs that will be searched by the application server's classloader in order to find utility classes and .jar files. This is an important improvement, since it allows multiple EJBs to reference one set of utility classes.
Using a combination of the WEB-INF/lib directory and the Class-Path: attribute, you can intelligently distribute your application files by:
1) Placing classes that are shared by more than one Web application in a common .jar file and adding a reference to the .jar file in the Class-Path: list of the application's manifest file.
2) Adding references to EJB support libraries in the proper manifest Class-Path: list.
3) Placing utility .jar files for a Web application in the application's WEB-INF/lib directory.
Dig Deeper on Microservices pattern, platforms and frameworks
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.