• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Struts and EJB framework

 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mr. Neal,
I am starting to work with Struts.
My applications make use of Struts (with Servlets and JSPs) and EJBs.
So far as I know, Structs contain something like ActionForm, which define which "page" or "what's next". It knows the workflow of the whole "function".
However, in EJBs with the help of JNDI, we can also have such a workflow locates in the Session Bean. When a page is invoked, it can then lookup the Service provider from JNDI, obtain the EJB object reference, and do the job, and then finally return the results to the JSPs/Servlets for display.
On this aspect, are there any difference? Cos some of my counterparts even said that, in fact, EJB with JNDI can do the same task as Structs, and thus, why we need to have both in the same system.
Please advice.
Nick.
 
Author
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nick -

So far as I know, Structs contain something like ActionForm, which define which "page" or "what's next". It knows the workflow of the whole "function".
However, in EJBs with the help of JNDI, we can also have such a workflow locates in the Session Bean. When a page is invoked, it can then lookup the Service provider from JNDI, obtain the EJB object reference, and do the job, and then finally return the results to the JSPs/Servlets for display.
On this aspect, are there any difference? Cos some of my counterparts even said that, in fact, EJB with JNDI can do the same task as Structs, and thus, why we need to have both in the same system.


Good question. Struts is more optimized for this kind of workflow -- EJB's are a little heavy-weight for this kind of work. The workflow in Stuts also has some distinct advantages:
  • Workflow is defined in an XML document, making it easy to change workflow without touching code.
  • ActionForms handle much more than just workflow. For example, they can help generate client and server-side validation code using declarative validation. This is useful for UI-style validations like formats, masks, required fields, etc.
  • ActionForms perform some nice automatic population of JSP elements that goes well beyond standard JSP .

  • This is not to say that you can't use EJB's for this. However, it brings up my favorite Simpson's quote. Marge says to Homer: "I didn't say that you couldn't deep fry your shirt, I said that you shouldn't deep fry your shirt." Just because you can doesn't mean you should. Struts is designed specifically for building web applications, and EJB's are not.
     
    Nicholas Cheung
    Ranch Hand
    Posts: 4982
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Neal,
    In addition, I feel that Structs is not that easy to develop, although it really provides a powerful framework on the Web applications.
    For example, I need to declare lots of variables (even the form variables) so that the form will appear in the screen promptly. If I need to make use of ActionForms, it is more difficult than I just use JSP with JSTL as it needs more!
    I understand that Structs somehow perform the tasks of what MVC defines, but it seems a bit more difficult to implement, isn't it?
    Nick.
      Bookmark Topic Watch Topic
    • New Topic