Making Struts Projects in IDEs
From Software By Jeff
Starting with Struts - Setting Up Struts - Struts Webserver Configuration - Our Struts Classes - Our Struts Web Pages - Struts Server Deployment - Making Struts Projects in IDEs
Here we'll discuss doing the Struts creation from scratch in our two favorite open-source Java integrated development environments.
More information coming
| Table of contents |
NetBeans
NetBeans sweetly comes with a Tomcat installation built-in, and it loves to create web applications for use on Tomcat. The deployment of these applications is built correctly in a container that is transportable, and can be done largely independently of the Tomcat server (e.g., so you can move it to other application servers). Other application servers can also be used, but for our simple discussion, we'll just use the built-in Tomcat.
Eclipse
Eclipse has a Web Tools Project that integrates much of the development and deployment with servlet and application servers. It has built-in deployment configurations for versions of Tomcat, JBoss, WebSphere, and others. Eclipse does not include an installation of any of these application servers, instead relying on a local installation to be performed independently.
Eclipse WTP
The good people at Eclipse have released a set of tools called the Web Tools Platform that includes all kinds of goodies for integrating web development into the IDE without the need for finding third-party solutions. Don't get me wrong; third-party solutions are great, but integrated packages are even better.
For Windows and LINUX there are downloadable packages that include all of Eclipse and the WTP tools in one easy installation file. For the Mac, or for an already installed Eclipse, download the updates using Eclipse's Software Update tool (in the Help menu).
Install Tomcat
Eclipse requires an external installation of the application server. We're going to discuss using Tomcat, but if your environment uses a different engine, don't worry, the instructions are fundamentally the same. Simply download and unpack the Tomcat core from Apache. No additional configuration is necessary as all of the Tomcat settings that will be affected by your project will remain within the workspace. This is essential as you may have many projects, or set up different configurations of Tomcat within Eclipse, and it won't affect the other configurations. You could even use a previously installed Tomcat that is actually running on the system with its own content; Eclipse is just going to use the binaries and common libraries.
Configure Eclipse
Once both the WTP and Tomcat are installed, it's time to configure Eclipse to use the Tomcat server. Open Eclipse, and then the Eclipse preferences. Find the Server, and install a new runtime. Select the version of the application server you're using, and provide a path to the server. Finally, tell the server which JRE or JDK to use. It's as easy as that. Sure a step-by-step or picture would be nice, but maybe later.
Eclipse Web Project
Once configured, setting up a Struts project in Eclipse is pretty straight forward. Start Eclipse. Create a new project by selecting File>>New>>Project. Find the Web group and in that select Dynamic Web Project. Just like other Eclipse projects, select a name and location for the files. Also select (or create if you haven't) the application server installation to use. For now we'll accept the defaults for everything else.
What you should end up with is a project that has Tomcat and the JRE as libraries, and a JavaSource and WebContent directory. Inside the JavaSource directory should be empty, and inside the WebContent directory should be only a WEB-INF directory.
IDE Integration
Use the previous information to build your struts projects. Copy the Struts library JARs to the WEB-INF/lib directory in your IDE's web source directory. Edit or create the web.xml as described previously. Create the Action and Form classes in the JavaSource directory.
Now start the server as is appropriate for your IDE, and the site should fire up and do whatever it is you wanted it to do!