What is Struts 2 and how it works

Author posted by Jitendra on Posted on under category Categories Struts and tagged as Tags with 6 Comments on What is Struts 2 and how it works

What is Struts 2 and how it works?

Struts 2 is the Open source web application Framework which simplified the creation of Web Applications in in Java. It is based on the Model – View – Framework (MVC) architect which is originally found in language “SmallTalk“.  Latest version of Struts is 2 and which is created by using concepts of WebWork and Xwork.

Flow of Struts 2:

How Struts 2 Works
How Struts 2 Works


  1. Request : Client makes the request.
  2. Filter Dispatcher : As Boot Strap component is specified in Deployment Descriptor file. In Case of Struts 2, it is Servlet Filter (Filter Dispatcher). Filter Dispatcher looks the request and then as per the mapping of URL, request is forwarded to appropriate Action Class.
  3. Interceptor Stacks : Before going to Action Class, request goes to Interceptor Stacks (Action class mapping found in configuration file, and from there, list of interceptors identified which must be processed before Action class) .
  4. Action Class : Then the request object is passed to Action Class. Action Class then executes the code and after execution it returns the result code to the Controller. (either SUCCESS or INPUT or ERROR)
  5. Result : On the basis of result code, Controller then selects View to be rendered as a result of Action.
  6. Interceptors Stack : Before sending response back to client, again interceptors run.
  7. Response returned to User.

Note: If interceptor changes the result return type then the view will be changed and decided after interceptor.

Related posts

6 thoughts on “What is Struts 2 and how it works”

  1. hi Shiva,

    Nice tutorial about struts framework. But i need to clarify some basics about struts. Please share those knowledge with us.

    1. What is Framework?
    2. Why we need struts and spring?
    3. What is the advantage between servlets ans struts?

    Please reply for above question.


    1. Framework is a platform which contains lot of libraries and code which is necessary to design an application. So Framework makes the application development very fast and easy. We can say that Framework means Programming with the available libraries and Jars.

      Struts is used to develop the Web Application because Java is not sufficient to develop a web application.

      Spring removes the tight coupling between the objects. Spring ensures that the objects are not dependent on another object.

  2. In Struts2 we will have pre-processing and post-processing requests.

    Pre-processing requests are the requests when client fires a request then before reaching action class filter stack check would be to modify the request , this is called as pre-processing.

    Post processing means if response is ready to send to the client then before sending response , again filter stack can be applied to modify the response and then send the response back to the client.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.