Struts 2 Getting-Started on Ubuntu 14.04 Trusty LTS Linux Easy Guide

June 15th, 2014 by thelinuxevangelist

Struts 2 Quick-Start on Ubuntu Linux

The Tutorial Shows You Step-by-Step How-to Getting-Started with Struts 2 Hello-World Java Web Application Ubuntu 14.04 Trusty Tahr LTS 32/64bit GNU/Linux.

The first benefit of using Struts is that you don’t have to write a Controller and can concentrate on writing Business Logic in action classes.

Struts 2 Features List:

  • Struts provides a Filter Dispatcher, saving you writing one.
  • Struts employs an XML-based Configuration file to match URIs with actions.
  • Struts instantiates the Action Class and populates Action Properties with user inputs. If you don’t specify an action class, a default action class will be instantiated.
  • Struts Validates user input and redirects user back to the input form if validation failed. Input validation is optional and can be done programmatically or declaratively. On top of that, Struts provides Built-in Validators for most of the tasks you may encounter when building a web application.
  • Struts invokes the Action Method and you can change the method for an action through the Configuration File.
  • Struts examines the Action Result and executes the result. The most common result type, Dispatcher, forwards control to a JSP. However, Struts comes with various result types that allow you to do things differently, such as generate a PDF, redirect to an external resource, send an error message, etc.

This Tutorial make Use of the Maven Java Tool Facility to Getting-Started Easy with a Basic Struts2 Web App on Ubuntu Linux.

Struts 2 can Use either an XML Configuration file or Java Annotations (or both) to specify the relationship between a URL, a Java class, and a view page (such as index.jsp).

Struts 2 Quick-Start on Ubuntu 14.04 Trusty LTS Linux - Featured
  1. Download All Apache Struts 2 Release

    Get Struts2 All .zip
  2. Open a Command Line Terminal Window
    (Press “Enter” to Execute Commands)


    Struts 2 Quick-Start on Ubuntu 14.04 Trusty LTS Linux - Open Terminal
  3. Double-Click on Archive and Extract into Home

     - Extract Apache Struts 2
    Or from Command Line:

    unzip -d $HOME/struts2 struts-2*
  4. Relocate Struts 2

    mv $HOME/struts2* $HOME/struts2
  5. Access Target Directory

    cd $HOME/struts2
  6. Check if Maven 3+ is Setup on Ubuntu

    mvn -version

    How-to Install Latest Apache Maven on Ubuntu

  7. Generate a Maven Standard Java Web App Project:

    Maven Create Web App Project
  8. Edit the pom.xml Config File

    cd myWebApp
    nano pom.xml

    Modify the “build” Entry like:


    Ctrl+x to Save & Exit from nano :)

  9. Add Struts 2 Jar Files To Class Path

    nano ./pom.xml

    Include in the “dependencies” Section:


    Just Subsitute to X.X.X.X the Suited Struts 2 Version (May simply Look the Latest Downloaded Struts Release!)

  10. Building and Packaging to Easy Deploy on the Servlet Container

    mvn clean package

    Find the Artifact Product Ready to Deploy on:

  11. How-to Deploy a Servelet on Apache Tomcat Container:

    Tomcat Easy Deploying Guide
  12. Then You can Browse the Struts2 StartUp Hello-World

  13. Add Logging

    This to see what’s happening under the hood…

    nano ./pom.xml

    Include in the “dependencies” Section:


    Then Create a Log4J Config File

    nano ./src/main/resources/log4j.xml


  14. Add a Struts 2 Servlet Filter

    nano ./src/main/webapp/WEB-INF/web.xml


  15. Struts 2 App Minimal XML Configuration

    nano ./src/main/resources/struts.xml


  16. Building and Packaging Again

    mvn clean package
  17. Deploy and Access the Final Struts2 Hello-World App

(Visited 730 times, 1 visits today)
Share on Tumblr

Tags: , , , , , , , , , , , , ,

Comments are disabled