I got a Java Webapp project which uses Struts2 as the controller layer. I need to check user’s permissions before doing anything (like opening a web page). I have developed an authorization system which is needed to be executed in struts action. So, how is it possible to execute this action before loading of a page? Should I use interceptors?
Share
You failed to understand the whole point of an MVC framework like Struts. In a MVC app, you should never have any link or form pointing to a JSP.
You should always point to a URL mapped to the Struts servlet/filter. Then the servlet invokes the appropriate action based on the URL, the action returns the result (the JSP to go to), and Struts forwards to this JSP.
If you point to a JSP directly, then you’re bypassing Struts completely. Read http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html