Solved

Model 2 Architecture of JSP

Posted on 2000-05-12
3
142 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Running Jira on Raspberry PI 2? 3 246
Java - Why doesn't this JFrame work 3 40
eclipse argument 14 53
map related example 6 24
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

947 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

22 Experts available now in Live!

Get 1:1 Help Now