Repost from JSP forum: Working with servlets jsp and javabeans
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Shaun_Lim
Posted On:   Sunday, March 7, 2004 11:36 PM

I am a java newbie but would like to properly seperate the business and presentation logic of my web application. I did it first by using servlets to do all processing and JSP only for presentation to the user. However, i passed data from servlets to JSP and vice-versa using session.get/set attributes. Upon further reading i discovered that i should use a JavaBean to do the transfering of data. Now I'm confused, should i do away with servlets altogether and just package the functions into JavaBeans or should it be JavaBeans <-> Servlets <-> JSP? Also, is it possible for a servlet and JSP to share the same instance of a JavaBean?    More>>

I am a java newbie but would like to properly seperate the business and presentation logic of my web application.


I did it first by using servlets to do all processing and JSP only for presentation to the user.


However, i passed data from servlets to JSP and vice-versa using session.get/set attributes.


Upon further reading i discovered that i should use a JavaBean to do the transfering of data.


Now I'm confused, should i do away with servlets altogether and just package the functions into JavaBeans or should it be JavaBeans <-> Servlets <-> JSP?


Also, is it possible for a servlet and JSP to share the same instance of a JavaBean?


Sorry for the long question. Please help. Thanks!


Shaun

   <<Less

Re: Repost from JSP forum: Working with servlets jsp and javabeans

Posted By:   Deepak_Kalra  
Posted On:   Sunday, March 21, 2004 09:05 PM

I will recommend use Servlet,JSP,Java Beans.


Use Servlet as Controller


Use Jave Bean for encapsulating all business logic


Use JSP for View



All request will go through controller servlet and servlet can decide to which view It should forward the request.
Before forwarding the request to JSP, Servlet can call
another Helper object for gathering all the required data
for the JSP



Thanks
Deepak

Re: Repost from JSP forum: Working with servlets jsp and javabeans

Posted By:   chris_hunter  
Posted On:   Friday, March 12, 2004 08:12 AM

You should use either JSP-JavaBean or Servlet-JavaBean. When to use a servlet or a JSP is up to you, but one approach is to use JSPs where there is a lot of straight HTML on the page and servlets for pages which requrie lots of java code. Any javabean can be called by either a servlet or jsp.


Chris

System Dynamics - Free website monitoring

About | Sitemap | Contact