Setting up File Structure in Eclipse and the WAR File Structure Step 7
Picture above is the Eclipse File Structure.
The ultimate goal is to build a WAR file that will be deployed to an application server, in our case Tomcat. The WAR file contains all the necessary files for your application. It will contain the configuration files, the Java classes, images and any other files that you will use for your application. The WAR file has a specific file structure as seen below. You will deploy your WAR file to the webapps folder in Tomcat and Tomcat will create the proper file structure when you start Tomcat.
Below is the Tomcat file structure. You will put the WAR file in the webapps folder. In that folder you have the META-INF folder which is used by Tomcat. You will have the resources folder which contains all your images, js and css files. In your WEB-INF folder you will have your JAVA classes, jsp pages, libraries and for some older versions of struts, the tld files. The WEB-INF folder will contain your struts.xml files and your web.xml file. You do not need to create this structure because Tomcat will create it for you.

Below is the Tomcat file structure. You will put the WAR file in the webapps folder. In that folder you have the META-INF folder which is used by Tomcat. You will have the resources folder which contains all your images, js and css files. In your WEB-INF folder you will have your JAVA classes, jsp pages, libraries and for some older versions of struts, the tld files. The WEB-INF folder will contain your struts.xml files and your web.xml file. You do not need to create this structure because Tomcat will create it for you.

The structure that you will have to build is the eclipse file structure. You should set up your file structure in eclipse similiar to the file structure in Tomcat. In eclipse you will have your Project. Under your project you will have your src folder which contains your JAVA packages. You will also have a list of any attached jar files that you are using in your project. The antbuild folder is a folder that you will keep your classes and war file in. You do not need to create this folder because it will be created in your ant script. The content folder contains your resource folder and your WEB-INF folder. The WEB-INF folder will contain your jsp, lib, and struts tld files (In our version of struts, we won't be using the tld folder). The WEB-INF folder will also contain your web.xml file and your struts config files.

You should open up your eclipse. If you haven't already picked your workspace, you should do that now. To create a new project you will select File, New and Java Project. You will want to name your project. I am going to call this project UserBook since it is about people who read books. After you name the project, you can press finish.
Eclipse should create a project for you.
You will see, under your package explorer, a project called UserBook. If you expand that project, you will see the folder src and the JRE System Library folders. You should go ahead and create the rest of the needed folders. Select the right mouse button over the UserBook folder and select new and source folder. After you have created that folder, you should create a folder called content. Follow the same procedures and under the content folder you should create a folder called resources and WEB-INF. Under the WEB-INF folder, you should create folders called jsp and lib. These should be regular folders, but your src should be a source folder.
Now your file structure is all set to begin development on your new project.
The tld folder isn't needed with newer versions of struts. The older versions of struts requires this folder to put the tld files in, but in newer versions of struts the tld files are contained within the jar files.


0 comments:
Post a Comment