With the release of the Java Servlet Specification 2.2, the concept of a Web application was introduced. According to this specification, a "Web Application is a collection of servlets, html pages, classes, and other resources that can be bundled and run on multiple containers from multiple vendors". That is, a Web application is anything that resides in the Web layer of an application.
One of the main characteristics of a Web application is its relationship to the ServletContext. Each Web application has one and only one ServletContext. This relationship is controlled by the Servlet container and guarantees that web applications will not clash when storing objects in the ServletContext.
The following items can exist in a web application:
The standard method for packaging Web applications is to use a Web ARchive file (WAR). You can create a WAR file by using Java's archiving tool jar (jar command). The extension must be .war
Suppose your current directory is greetings as: c:\snr\greetings>
greetings is a folder that contains all the files required for a WAR file. A WAR file should contain all the files to make it to work independently as one unit.
Now create the WAR file as follows:
c:\snr\greetings> jar -cvf wishes.war *
Asterisk, * indicates to include all the files and subdirectories of greetings folder.
Now by name a file wishes.war file is created.
Copy wishes.war into Weblogic's (of Weblogic 8.1 version) applications directory available as follows:
Now run the weblogic server and type from the browser prompt as follows:
where myData is the url-pattern name of the servlet written in your web.xml file. Remember this servlet file is in the classes directly of your Web application. 7001 is the port number on which Weblogic server is running.
A similar program is available but creating WAR file in Tomcat server WAR File in Tomcat with Creation, Deployment, Execution.