[MUSIC] Web containers require that your application be packaged in a very specific format in order to be able to run it. So, one of the important things that you have to learn when building a Java based or servlet based cloud service, is how do you package up your code in a way that any web container that follows the Java specification can run your code. So there's a standard format for packaging your code in order to deploy it and run it on a web application container. And the way that you do that is through what's called a WAR file, or web application resource file. So, the war file is where you package all of your code and all the configuration information in order to deploy your code to a web application container. Now, one of the important things to note is this isn't really a fancy file at all. There's no special work that you have to do to create one of these files other than follow some basic guidelines. A WAR file is just a Zip file that follows a standard directory structure for placing your code and configuration files inside. And there are a couple important pieces of the WAR file. The first one is the web folder. And one of the important things to note about this folder is that it is a private folder that specifies configuration files, code, and other things that you don't ever want returned to the clients that are requesting information from your web container. So, this is things like the configuration files that may specify where your database servers are located and what ports are on, security things that you wouldn't necessarily want exposed. So, the WEB-INF director is where you store that information. Now, we talked before about the web.xml file. The web.xml file is the file that tells the web container these are all of the servelets in my application. Here are the class names of the classes that I want to service servlets and receive various request from clients. And that web.xml file that specifies the mapping that the server's web container should use to determine which servlet receives a particular HTTP request, is specified inside this web XML file which lives in the WEB-INF folder. And obviously this is a configuration of file that you don´t want you clients to see for security reasons and also potentially for proprietary information or implementation reasons. So, the web.xml file lives within this WEB-INF and folder. What 's important to note is that everything else, all of the other directories, which you can have arbitrary directories like you could have a JavaScript directory where you store JavaScript files. You could have HTML, you could have views, you could have whatever directory structure you want, in the rest of the web application resource or WAR file. But the important thing to note is that this is always going to be a private directory, the WEB-INF file. So, anything you put anywhere else in your WAR file the web container can potentially serve that resource up in it's raw form, and return it to a client that is requesting it. So, all of your really sensitive stuff always needs to go inside of the WEB-INF folder. There are a couple of other sensitive things that typically go inside of this folder. One is your classes directory. And this is where your compiled Java files for your application, for example, the classes that you have created to implement servlets. This is where those files will go and they will be laid out directly beneath the classes folder just using your typical java package structure and you will have all of your class files within various directories underneath the classes directory. The other thing that you will typically see in WEB-INF a lib directory. And lib then will have various jars that your application depends on like foo.jar, whatever else. But you can create any of your own directories as well underneath WEB-INF that can store custom configuration information or organize things. But the important thing to always remember is, if you have something that you don't ever want to be returned to a client, it needs to go in WEB-INF. If it's not in WEB-INF, if it's somewhere else, in some other folder, then the web container could potentially return it. So, the way that you create one of these WAR files is you create a directory structure that matches what you want your WAR file to look like. That is, you create a folder that inside of it has a WEB-INF folder, has the various web.xml, and classes, lib, the other important folders that you need within it to specify the configuration and the code for your app. It has the various resources that are at the root of the WAR or folders from the root. And then you simply take that folder containing all this stuff, zip it up into a file, and name it .war, and you've then created a WAR file that can be deployed to a web container. So it's not difficult at all. All you need to know is the basic rules. Create your WEB-INF file, create your web.xml, put your classes in classes once they've been compiled and with all of your rest of your resources, hanging somewhere off of the folders from the root of the WAR file. Now there are lots of tools that can be used automatically, setup the structure for you to build your code and place it into a WAR file. There's automated build tools like Maven, which we won't go into in this class or Gradle can do this for you. App engine does this in the background when you deploy to Google's app engine cloud and we'll see some of that in later lessons. But all of this is very simple and you can do it by hand if you want to or you can write scripts to do it or use some of these tools.