This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Why to user JSP or BEAN or EJB when everything just happen with servlet ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

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

Dharmin Desai
Ranch Hand

Joined: Feb 28, 2002
Posts: 81
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)


SCJP2 (93%),SCWCD(88%)<br />-------------------------------<br />Never under estimate yr self, just represent yr profile in proper manner.
bharat nagpal
Ranch Hand

Joined: Oct 26, 2002
Posts: 76
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

Joined: Aug 29, 2002
Posts: 47
you may find this link useful:
http://developer.java.sun.com/developer/restricted/patterns/J2EEPatternsAtAGlance.html
Ebage
SCJP
SCEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why to user JSP or BEAN or EJB when everything just happen with servlet ?
 
Similar Threads
How to implement MVC architecture with J2EE ?
When to use Jsp when to use servlets and when to use Bean / EJB ?
problem in calling entity bean from session bean
Distinction between Stateful and Standard session bean.
Servlets vs JSP