• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

When to use Jsp when to use servlets and when to use Bean / EJB ?

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Friends,
Anybody can answer following questions ?
1. Why to use JSP or Java Bean or EJB, when everything can be done with Servlets ?
=> Bean and EJB is reusable component so one can understand the use for Bean and EJB, But why servlet or Jsp ?
2. Moreover, Which things (java code), i need to put at Jsp and which code i need to put at Servlet and again which code should be at Bean/EJB ?
3. Anybody can help to implement MVC Architecture with J2EE technology ?
Thanks and regards
Dharmin
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
you can do everything using JSP what ever u can do with servlets.but coming to servlets, u have to combine both HTML and java code which is tedious when the HTMl code is huge.In this situation using JSP is very comfortable, as jsp seperates presentation logic and business logic.
The same java code will work both in servlets and JSP's.It's always good to use the combination of servlets and JSP.
coming to MVC architecture--> use EJB's as model and JSP as View(presentation part)and servlets as controller
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wouldnt it be a lot of work writing a servlet to display a page when the only java code needed is this: request.getParameter("name")?
jsp also has the advantage that you dont have to recompile and then restart the server to make changes.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP decouples presentation from logic. So any page change is simpler. servlets should be used for business logics or can be Front controller or can be just a controller. JavaBeans can be reusable data components. EJB can be used to implement Value Object pattern.
Just read J2EE design patterns that will help you understand the role of each of these.
 
Dharmin Desai
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks friends,
Actually, i need to do some more homework !
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But please remember that JSP is not the only page-building technology.
A templating approach (such as WebMacro or Velocity) offers the same benefits of separating presentation from logic, without the hideous JSP syntax and the irritating compilation step on the deployment box. And the powerful expression language built into either WebMacro or Velocity is miles ahead of the first clumsy steps in the JSP Standard Tag Library.
Similarly, EJB is not the only option for persistence of data.
Fundamentally EJB is just an object-relational mapping system, and there are several of those to choose from. Decoupling details of the storage mechanism from the object model is usually a good choice, but you don't always need EJB to achieve it.
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic