HttpServletResponse response, (Remote web server) UserContainer userContainer ) throws Exception; //

HttpServletResponse response, UserContainer userContainer ) throws Exception; // This super Action is also a good place to put commonutility methods public boolean isLoggedIn( HttpServletRequest request ){ UserContainer container = getUserContainer(request); return ( container != null && container.getUserView( ) != null ); } /** * Retrieve the UserContainer for the user tied to the request. */ protected UserContainer getUserContainer(HttpServletRequest request) { HttpSession session = request.getSession( ); UserContainer userContainer = (UserContainer)session.getAttribute(IConstants.USER_CONTAINER_ KEY); // Create a UserContainer if one doesn’t exist already if(userContainer == null) { userContainer = new UserContainer( ); userContainer.setLocale(request.getLocale( )); session.setAttribute(IConstants.USER_CONTAINER_KEY, userContainer); } return userContainer; } } The StorefrontBaseAction class shown in Example 9-4 illustrates how you can use a base Action to perform repetitive behavior so that all of the subclasses need not perform it themselves. Suppose, for example, that all of your Action classes needed to obtain the UserContainerfor the current user and use some information within it (e.g., user ID or security permissions). One approach is to force all of the Action classes to obtain the UserContainer on their own, handle the situation when there isn’t one, and so on. An alternate, more manageable approach is to put that behavior in a super Actionand pass the UserContainerto the subclasses. As Example 9-4 shows, the StorefrontBaseAction implements the execute( ) method, but inside that method, it gets an instance of a UserContainer and passes it as an argument to
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Leave a Reply