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

2 comments:

Anonymous said...

I cant download code !

Carlo on Data/Software engineering said...

I have long time without touching this,
But you can surely download it with your svn client like this:

svn checkout http://struts-cookie-interceptor.googlecode.com/svn/trunk/ struts-cookie-interceptor-read-only

Regards,