This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

Why to user JSP or BEAN or EJB when everything just happen with servlet ?

 
Dharmin Desai
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • 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 (SCJP)
 
bharat nagpal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Report post to moderator
1. Why to use JSP or Java Bean or EJB, when everything can be done with Servlets ?
2.

Jsp is used sometimes instead of Servlets
- servlets mix Presentation with business logic .
Its very important to seperate different layers. like jsp pages are maintained by design team ,
and business logic is responsibility of the Development team, and so on.....
its very-2 important for extensiblity.

we use JSP with Beans , because there should be ideally minimal java code in JSP , so we
write business logic in Beans and call the beans from JSP. so that desinger only deals with
<jsp:useBean>

with EJB you can write Enterprise application , without writing own distributed and complex code, you
can just concentrate on business logic and the EJB server handles all the complexities for you.
which is very important for critical applications. EJB development and maintenance cost is very high
,so they are generally used for critical applications

there are number of good books as well as tutorials, you better spend some good time there
3. Anybody can help to implement MVC Architecture with J2EE technology ?
yeah....
first you get your doubts clear about the above things
there are different ways you can implement MVC
I'm giving you a little example

let your Source Jsp is first.jsp, and the target is second.jsp

when you click a link on first.jsp , second.jsp should appear and should show a table of value
fetched from the database

first.jsp will call ControllerServlet (passing the required information like nextPage,and task)
controller Servlet will call Worker Servlet which in turn calls DataBean and get the required
data.servlet will load this data in ViewBean and forward the request to Target JSP, which uses ViewBean
and display the data in the table....
This is brief example...hope this is correct
if you need help you can mail me at bhart_n@yahoo.com
hopt this helps
 
Christian Ebage
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Report post to moderator
you may find this link useful:
http://developer.java.sun.com/developer/restricted/patterns/J2EEPatternsAtAGlance.html
Ebage
SCJP
SCEA
 
    Bookmark Topic Watch Topic
  • New Topic