Main Content

Java beans and classes, .war and .jar files

Archive - Originally posted on "The Horse's Mouth" - 2007-02-10 05:42:01 - Graham Ellis

A Java Bean is a class that includes a constructor that takes no parameters, and getter and setter methods with names like getLength and setLength to read and write properties. So at a basic (Java) level, a bean is just a class that happens to conform to some conventions. However - when you come to tag libraries such as those used in Java Server Pages (JSPs), the convention becomes a mandatory rule that must be applied to make the class usable in this way.

A .war file (Web Archive file) is a .jar (Java Archive file) that includes a welcome file such as index.html at the top level of the tree, and a subdirectory WEB-INF that contains a web.xml file. So at a basic level, a .war file is just a .jar file that happens to conform to some conventions. However - when you come to deploying web applications in a container vehicle such as Tomcat, the conventions become mandatory rules that much be followed if the web application is to deploy correctly.