Diego Magalhães
Diego Magalhães

Reputation: 725

Session handling in Struts 2.1.6

I have a project with the following setup:

Tomcat 6.x
Struts 2.1.6
DisplayTag 1.2
Spring 2.x (1 or 5, don't remember now)

I want to know to to do session controlling in every action of my app, like if the users weren't logged in, they're redirect to certain page to login (in the case of my project, either the user come to a special crafted url like login/SPECIALHASHTOLOGIN or won't enter at all.

Need more details?

Thx in advance.

Upvotes: 0

Views: 1869

Answers (2)

Barett
Barett

Reputation: 5948

Acegi security is a great way to add security to your web app if you're already using Spring. Here's a decent 1-hour Acegi tutorial.

Upvotes: 1

Rich Kroll
Rich Kroll

Reputation: 4005

I'm still new to S2 as well, but I believe what you will need to do is modify the default interceptor stack (or create a custom stack) and add a custom interceptor. This custom interceptor will need to implement SessionAware to access the user session, and must implement your custom logic (which action to redirect to, which URLs do not need protection, etc.).

Here is a good tutorial of a LoginInterceptor that behaves similar to what you are requesting.

Upvotes: 1

Related Questions