Tuesday, October 13, 2009

Struts 2 cookie interceptor

A few weeks ago i developed a Struts2 cookie interceptor plugin.

I just upload it to http://code.google.com/p/struts-cookie-interceptor/

The interceptor is a Bidirectional interceptor (In Out interceptor) that works the following way.

in your action you annotate a property declaration like this:

@Cookie("cookie")
private String valor;
.. getter...setter

Then, the interceptor will inject the value of the "cookie" cookie to the annotated property. If the value of the property "valor" is changed in the action, this value, will be written to the cookie on the return of the action automatically. this is way i say it is bidirectional.

The annotation takes as values, the name of the cookie, the path, and the time to live attributes.

For full detail, feel free to download the source code.

Bye