views:

765

answers:

2

Hello folks,

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.

+1  A: 

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.

Rich Kroll
Wondeful, just like what i need it.Thanks.
Kamia
do you have any more struts2 good links to share? thanks once more.
Kamia
+1  A: 

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.

Barett
thanks for that, i'll have look at it.
Kamia

related questions