Open In App

Create and Setup Struts2 Dynamic Web Application in Eclipse

Improve
Improve
Like Article
Like
Save
Share
Report

Apache Struts 2 is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model–view–controller architecture. In this article, we will see how we can create a Struts 2 application. Before creating your first Struts2 project it is important to make sure that you have the Apache Tomcat server installed and configured with Eclipse IDE. Now, if the above conditions are fulfilled, follow all the steps below. We will use Eclipse IDE so that all the required components will be created under a Dynamic Web Project. Let us now start with creating Dynamic Web Project.

Creating Dynamic Web Project

First, you simply need to start your Eclipse IDE and create a new Dynamic Web Project project. To do this go to File > New > Dynamic Web Project and enter the project name as per your wish. We have named it “First_Struts2App”.

 

Set the rest of the options as given in the following screen

 

Select all the default options on the next screens and don’t forget to check the Generate web.xml deployment descriptor option

 

This will create a dynamic web project for you in Eclipse. Now to run the Struts2 application, you need to set up your application with the Struts2 framework.

Download and Setup Struts2 Libraries

  1. You need to download and install Struts2 on your machine. Download the latest version of Struts2 binaries from here.
  2. At the time of writing this article, I downloaded struts-2.5.30-min-lib.zip
  3. After unzipping the downloaded file, you will get files inside struts-2.5.30/lib as follows

 

Now copy all the files from the struts-2.2.3\lib folder to your project’s WEB-INF\lib folder. You can also do this by simply dragging and dropping all the files into the WEB-INF\lib folder. Your project structure should now look like this:

 

Now you are done with your Struts2 application set up in Eclipse. You can further build your struts 2 application.


Last Updated : 20 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads