Struts 2 in Action Notes Chapter 1, Chapter 2

July 23, 2012 Leave a comment

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.

Categories: Notes, Struts 2 Notes

JPA2 @ManyToMany – A simple Standalone application

January 1, 2010 Comments off
The many to many relationship is between Authors and Books. There could be many authos for a given book. And an author can write many books.
The book class looks something like this:


@Table(name = "BOOKS")
public class Book {


@GeneratedValue(strategy = GenerationType.IDENTITY)

@Column(name = "BOOK_ID")

private int id;

@Column(name = "BOOK_NAME")

private String name;

@ManyToMany(cascade = CascadeType.PERSIST)

@JoinTable(name = "BOOKS_AND_AUTHORS",

joinColumns = @JoinColumn(name = "BOOK_ID"),

inverseJoinColumns = @JoinColumn(name = "AUTHOR_ID"))

public List<Author> bookAuthors;

Categories: Uncategorized

Get every new post delivered to your Inbox.