First of all setup Eclipse Ganymede for Java EE and add to it a Tomcat6 server, as described in my previous tutorial.
Choose, from the File menu New, Dynamic Web Project in the option panel, give a name to the project (i.e. Struts2-Rest), choose a Target Runtime (that you should have already defined, in my case, Apache Tomcat v.6.0) and click Next.
Here you can define the web application context root, that’s the relative path where it will be accessibile, if you choose Struts2-Rest
as context root, your application will be accessible on http://www.yourserver.com/Struts2-Rest
or http://localhost:8080/Struts2-Rest
if you use the default Tomcat configuration provided by Eclipse (with the Tomcat HTTP Connector on the port 8080)
The Content Directory parameters defines the directory inside your project where is located the “root” of the .war you’re going to generate, use the default WebContent
directory.
And, obviously, Java Source Directory defines the directory where your Java sources will be stored. Just for your information, after compilation, the generated .class
files are automatically moved by Eclipse into WebContent/WEB-INF/classes
.
Just click finish. Your brand new project will appear in the Project Explorer
The Deployment Descriptor is obviously associated with the web.xml file. The Java Resources (src
) contains your source code, and WebContent
contains all the .jsp
files, the static contents (images, css, javascripts) and the WEB-INF directory of your .war that will contain the compiled classes (in /WEB-INF/classes
) and the libraries (in /WEB-INF/lib
).