Am Sonntag, 12. Oktober 2003 02:53 schrieb Kunal H. Parikh: > Hi All ! > > I am trying to start out with struts. > > I have successfully deployed an EJB in JBOSS and want to call it from > my Struts-based web app.
-- CLIP! > My Questions: > ============= > 1. Should I call my EJB from the execute method and set the > attributes of the UsedVehicleEJB as session variables? > > 1.1 Can I make the entire EJB a session variable? > > 2. Should I be using the bean tag library in my view > "searchUsedCars.jsp" to call my EJB ? > > > What I think: > ============= > Given that the view should be independent of the model, I should not > call the EJB from "searchUsedCars.jsp" and hence, I should call the > EJB from the execute method. No? :-) In fact, you should strictly separate the different layers and hide the implementation details behind interfaces (not necessarily meaning the datatype here). Struts is part of the web tier, and though some people may think different, even Actions are not part of the Model, but means to interface with the model. I can't lay out the details here in full ("J2EE is much too complex" :-), but it might be a good idea to make yourself familiar with some Patterns; SessionFacade, Business Delegate, Data Access Object and Value Object (though I'm not sure if the latter is still an 'official' J2EE blueprints pattern) in particular. Apart from that, I would strongly recommend reading a good book on these matters. One that instantly comes to my mind here is 'Programming Jakarta Struts' by Chuck Cavaness (O'Reilly) which IMHO is a very recommendable book on Struts itself. Apart from a lot of other things, he shows how to port a DAO to one accessing the EJB tier in replacement of a JDBC implementation (Chapter 13; written by Brian Keeton actually) Though the chapter is rather short and J2EE is complex, it still includes everything you absolutely have to know about interfacing to the application tier. If you're serious about EJBs, you'll need a lot more of background knowledge. One of the books I can recommend in this direction is 'Java Enterprise Beans' by Richard Monson-Haefel (also O'Reilly; no, I'm not being paid by O'Reilly, and their book on Oracle SQL (the one with the scorpion) is rather useless, apart from the introductory chapter about the history of SQL which is entertaining at least). Another resource that is a must are the J2EE blueprints, of course (http://java.sun.com/blueprints/). So after all, it's neither a good idea to call an EJB from a JSP page nor doing so from an Action. HTH, -- Chris. > Please comment. > > > TIA, > > Kunal --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]