Monday, September 1, 2003

Become a Struts wizard using WebSphere Studio V5


By Dan Velasco

Struts is an open source framework for building Java web applications. Do you want to be a Struts wizard? Do you use WebSphere Studio for your application development? If so, you can use the power of WebSphere Studio and its built-in wizards to easily create Struts-enabled applications to impress your friends and neighbors (OK, so it will only impress other geeky developers, but that's enough, isn't it?).

Here are the steps to add Struts support to your web applications by using the power of WebSphere Studio.

Make sure you are in the Web Perspective and then select File --> New --> Web Project. On the first dialog box, give your project a name and then in the "Web Project features" section at the lower left, just click the checkbox next to "Add Struts support" as shown in Figure A.


Start your Web project by clicking Add Struts support. (click for larger image)

Click next, then fill out the "J2EE Settings Page," and click next again. In the "Struts Settings" dialog box, keep the default settings if this is your first Struts application. If you're more experienced with Struts, you can choose to override the default settings by clicking the checkbox.

Click the Finish button and your new Struts-enabled application will be created for you.

What you'll notice is that all of the files you need to create a Struts-enabled application have been configured for you. For instance, you'll see the following items:

Under the Java Source folder:

  • A resources folder and file off of the Java Source folder

Under the Web Content folder:

  • All of the JAR files you need in the WEB-INF/lib directory.
  • The tag library descriptor files in the WEB-INF directory for using the Struts custom tags
  • A default struts-config.xml file for configuring your Struts application

Now, here's where I slip in a little mini-tip inside the tip. You may have noticed that there was a Struts version on the Struts Settings page. When I first started using the wizard to create Struts applications, the version was at 1.1 (beta 2). What's cool is that there is a way to easily upgrade what version is available by simply upgrading WebSphere Studio.

To upgrade WebSphere Studio, go to Help --> Software Updates --> New Updates. When I ran this I saw the dialog box shown in Figure B telling me there were updates available.


Select the updates you want to install. (click for larger image)

I installed them, and then the upgrade process prompted me to restart WebSphere Studio. Note that the first time I ran this it took quite a bit of time, and you need to be sure to have a high-speed Internet connection in order to download all of the software updates.