beginners question on JSP Action


Web tier: servlets, JSP, Web frameworks: beginners question on JSP Action

  1. beginners question on JSP Action (3 messages)

    Can somebody help me with translating the following into a JSP action or is it not possible and do I have to keep my scriptlet in the JSP? (I'm not allowed to use JSP 2.0) UserData contains all the data concerning 1 user the definition of UserGroup public class UserGroup { private static Map users = new HashMap(); public static UserData getUser(String userid){ return (UserData) users.get(userid); } ...
  2. Re: beginners question on JSP Action[ Go to top ]

    you should put that in an Action Class. no business logic should be on the page, only Presentation code. public class UserManager{ public UserData getUserDataById(String userId){ UserData userData= null; UserDAO userDAO = DAOFactory.getUserDAO(); User user = userDAO.getUser(userId); if ( user != null){ userData = user.getSettings(); }else{ //fatal? throw new Exception("user does not exist.."); } } return userData; } UserDAO just has CRUD methods UserDAO public findAll(); public User getUserById(String id); public delete(); ... in the Action class simply use the UserManager. UserData userData = userManager.getUserDataById(id); //Handle if it is null, or exception..try catch..above.. request.setAttribute("userData",userData); in the JSP if u are using struts access it simply that way..
  3. Re: beginners question on JSP Action[ Go to top ]

    thank you, this is a great help I'm learning it all in trying to rewrite a legacy application. So it's the purpose to remove all the business logic to a separate layer. I see now that I got stuck because I tried to stay to close to the legacy code. So thanks again.
  4. Re: beginners question on JSP Action[ Go to top ]

    email me if u need something else.. yes remove it, and u should be using a MVC framework as well like Struts. Model = ActionForm, model objects View = the JSP Control = the Action Classes, that access your service classes.