Notes · Struts 2 Notes

Struts 2 in Action Notes Chapter 1, Chapter 2

I am drafting some notes from Struts 2 in Action. I used this book to learn Struts 2 framework which was one of the few good resources available at the time when I started with the framework. While reading it, I made some notes for myself. I am compiling those here. I am just documenting the notes here for a quick reference when I don’t have an access to the book. I hope I am not violating any laws. But if I am, please let me know, I will take down the content. Also, at times, I have added my own text, here and there, based on my understanding. So the notes here may not match the text from the book. For better reference, please refer to the book.

Chapter 1

Definition of Struts 2 interceptor:

Interceptors are Struts 2 components that execute both before and after the rest of the request processing. They provide an architectural component in which to define various workflow and cross-cutting tasks so that they can be easily reused as well as separated from other architectural concerns.


Definition of ValueStack:

Struts 2 uses the ValueStack as a storage area for all application domain data that will be needed during the processing of a request. Data is moved to the ValueStack in preparation for request processing, it is manipulated there during action execution, and it is read from there when the results render their response pages.

—the ValueStack is where your data is stored while you work with it,and that OGNL is the expression language that you, and the framework, use to target this data from various parts of the request-processing cycle.


Chapter 2

Using annotations for declarative architecture

    @Result(name="input", value="/Registration.jsp" )
    @Result(value="/RegistrationSuccess.jsp" )
public class Login implements Action {
    public String execute() {
        //Business logic for login

A sample web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns=""
	<display-name>S2 Example Application - Chapter 1 - Hello World

The value of init-parameter actionPackages passed to the FilterDispatcher should give the names of packages where we have used annotations (for example, @Result)

Use empty action components to forward to your results, even if they’re simple JSPs that require no dynamic processing. This keeps the application’s architecture consistent, prewires your workflow in anticipation of increases in complexity, and hides the real structure of your resources behind the logical namespace of the Struts 2 actions.


Leave a Reply

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

You are commenting using your 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