struts 2 sucks

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

struts 2 sucks

sensible_guy
The reason being OGNL. OGNL is a context scope map, pretty much similar to Expression Language (EL) just that EL atleast had mapped all elements to either of the scopes, page scope being the default.

consider the following scenario, create a sample web application using struts 2 and allow for multiple users to logon simultaneously on the server. each user, configured to a different realm or privilege group would get to see a different dashboard pane. the dashboard should provide links that navigate the user through specific set of screens, defined specifically for the user group. no two user groups screens should match or be re-used.

with multiple users logging on simultaneously, the web application is going to break!!! any guesses!!!!

Solutions to challenge the scenario will be appreciated.

Reply | Threaded
Open this post in threaded view
|

Re: struts 2 sucks

matt.payne
Struts 2 > You.

Your not the first person in the world that needs to store users in the session via a Struts 2 application.

Ognl does not limit you from having session scoped variables.

You can still refer to a session in actions if you need to.
e.g.

ActionContext.getContext().getSession().remove(User.SESSION_NAME);

or see ServletRequestAware, ServletResponseAware aware interfaces

For "Seam" style scopes see
http://cwiki.apache.org/S2PLUGINS/scope-plugin.html

Below is code from a login implementation for an application i've done in the past.

        public String logon() throws Exception {

                AuthenticationResult result = authenticator.authenticate(user.getUserId(), password);

                if (!result.isAuthenticated()) {
                        addActionError(getText("error.badpass"));
                        return INPUT;
                } else {
                        user = (User) result.getPrincipal();
                        request.getSession().setAttribute(User.SESSION_NAME, user);
                        log.info("User " + user.getUsername() + " logged in");

                        if (rememberMe) {
                                String cookieValue = user.getCookie();
                                if (user.getCookie() == null || user.getCookie().trim().length() < 1) {
                                        cookieValue = userManager.generateCookieValue();
                                }
                                user.setCookie(cookieValue);
                                String cookieName = userManager.getCookieName(user);
                                Cookie cookie = new Cookie(cookieName, cookieValue);
                                // cookie.setPath("/");
                                cookie.setMaxAge(31536000); // 60 * 60 * 24=86400 (1 day) * 365
                                // days = 31536000
                                response.addCookie(cookie);
                                userManager.persist(user);
                        }

                }

                return SUCCESS;
        }
Reply | Threaded
Open this post in threaded view
|

Re: struts 2 sucks

dynamicd
In reply to this post by sensible_guy
I am trying to build something similar. I have already started using Struts2 .. Lets see what happens.
I am using acegi to manage the user authentication and autorization.