Ask the Expert

What is a WAR file?

What is a WAR file? How can I use this efficiently in my Web applications, as I am using JSP, EJB, XML?

    Requires Free Membership to View

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.


This was first published in September 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: