EJB, Servlet, JSP help
I have built a small application which creates/maintains company divisions following the MVC design pattern.
I now want to move the methods which create,update, add objects out of the controller possibly into the Model servlet. This I hope would allow other parts of the application (not yet built) to manipulate division objects and not have to do this through the Contrroller which is used to call the JSP and present data.
I am wondering whether I should do this, or whether i should just move straight to Entity Java Beans, which I believe handle all interfaces with the database.
If you reckon this is the correct way forward can you tell me where I can see a good example i.e. has EJB which handle all dtabase communication and can talk to the controller servlet and the jsp.
[820 byte] By [
mikeahmad] at [2007-9-26 1:17:20]

Hello,
It is good to move business logic, especially if it is directly accessing the database, into EJBs. You will get benefits that will for example make your application more scaleable; the application server will manage the life cycle of the EJBs and make sure it will keep working when there are lots of clients simultaneously.
You should also use a connection pool of database connections instead of directly opening connections to the database.
Have a look at the "standard" example: the Java Pet Store application. You can find it here:
http://java.sun.com/j2ee/blueprints/
regards
Jesper
Hi,
We cover these issues in our book Core J2EE Patterns and also include some basic refactorings for J2EE, including moving from a non-EJB to EJB environment in phases.
Good luck,
Dan
> I have built a small application which
> creates/maintains company divisions following the MVC
> design pattern.
>
> I now want to move the methods which create,update,
> add objects out of the controller possibly into the
> Model servlet. This I hope would allow other parts of
> the application (not yet built) to manipulate division
> objects and not have to do this through the
> Contrroller which is used to call the JSP and present
> data.
>
> I am wondering whether I should do this, or whether i
> should just move straight to Entity Java Beans, which
> I believe handle all interfaces with the database.
>
> If you reckon this is the correct way forward can you
> tell me where I can see a good example i.e. has EJB
> which handle all dtabase communication and can talk to
> the controller servlet and the jsp.
>