Solved

Model 2 Architecture of JSP

Posted on 2000-05-12
3
140 Views
Last Modified: 2010-04-01
In Model2 Architecture of JSP,
We are using Servlets,JSP's and Beans.
In this, Beans are connecting to Other
Resources.
That means, in Beans only , we have to
do the Database Transactions.
Then what about the connection pooling.
Will Bean takes care of Connection Pooling.
Where as in Servlets, Connection pooling will be taken care by Server.
Even, we can write the Connection once
in the init() method Servlet Cycle and
use it in the whole Servlet Program.

So, I would like to know about where to take care of the database Transactions
whether to be in Servlets or in Beans or in JSP's.
0
Comment
Question by:java_world
3 Comments
 
LVL 5

Accepted Solution

by:
msmolyak earned 75 total points
ID: 2804480
According to the J2EE architecture, the transactional access to databases is best implemented in the Enterprise Java Beans. The EJB run in an application server which manages the transactions. Application servers usually support database connection pooling as well.

If using EJB is not an option for you, you can access databases from each kind of program you've mentioned. But then transaction management and conection pooling are up to you to implement. I would arrange them in the order of decreased preference as

Java Beans
Servlets
JSP

You typically do not whant to put any business logic in JSP, they should access Java Beans containing the business logic (the whole idea of JSP is that they are written by non-Java programmers) . It is similar with servlets, which should serve more as controllers than as business logic containers.
0
 
LVL 2

Expert Comment

by:sjhyam
ID: 2804601
Dear Friend!
  It is also possible to maintain a Connection Pooling using a bean. But,imagine what happens if we created more than one object for that bean. Then multiple connections will be opened, which in turn increase the traffic. So ,it is better to maintain Connection pooling in Servlet init() method. In JSP Model 2 Architecture Servlet is said to be controller--which decides about which bean to instantiate to process the clinet request. So, obviously it the controller's duty to maintain a connection to the resources--at least in this case, which needs multiple connections to a data base.

bye
shyam sunder reddy
0
 
LVL 7

Expert Comment

by:Ravindra76
ID: 2804725
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now