4 easy steps to load Strut2InAction source

Currently I am reading Struts 2 in Action. This is my second book from Manning publication. My first book was JQuery in Action which is awesome.  As I completed the second chapter in Struts 2 I like to try out the sample HelloWorld program.  So I downloaded the source code from manning website. I am able to play with HelloWorld in few minutes by deploying (copying) the downloaded war inside Tomcat 5.5.  However I also want to make a development setup in my eclipse so that I could try out certain things after changing the downloaded source. Unfortunately I am not able to make this easily. My search for a document explaining the step to import the downloaded source in to eclipse also went in vain. After a struggle of few hours, got the downloaded source integrated with Eclipse. Today, we’re going to take a closer look at the steps to load the downloaded source in to eclipse.

Note: Below steps explains about loading Struts2InAction (war). The same applies to HelloWorld.

Step 1 – Extract the war file

Open the war file using some extraction utility like Winrar. Extract the contents in to Struts2InAction(create new) directory in your workspace.

Figure 1 - Extracting

Figure 1 - Extracting

Step 2 – Create a Eclipse project

We need to create a Dynamic Web Project in eclipse.

Figure 2 - Creating a new project

Figure 2 - Creating a new project

Enter the project name as “Struts2InAction”. Select the directory created in Step 1 as value to project contents

Figure 3 - Dynamic Project

Figure 3 - Dynamic Project

Click Finish. A new project will be created with all the source code imported as shown in the below figure,

Figure 4 - Wrong directory structure

Figure 4 - Wrong directory structure

Step 3: Files re-arrangement

We need to make certain re-arrangements before successfully running the applications.

  1. Copy all Chapter* directories in to WebContent directory
  2. Copy menu, images in to WebContent directory
  3. Copy index.html in to WebContent directory
  4. Replace Struts2InAction/WebContent/WEB-INF with Struts2InAction/WEB-INF

Note: Do the above steps using windows explorer. After copying refresh the project in eclipse.

Once the above steps are done, the workspace will be re-structured as shown below

Figure 5 - Project Structure

Figure 5 - Project Structure

Step 4 – Run and Have fun

Now on a single click the application will be running within eclipse.

Figure 6 - Running Application

Figure 6 - Running Application

Hope this blog helps you in saving your valuable time. The same procedure applies to creation of any “Dynamic Web Project”. Let me know if you find more easier way to achieve the same.

Add to FacebookAdd to NewsvineAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Furl

Advertisements

One Response

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: