Solved

Model 2 Architecture of JSP

Posted on 2000-05-12
3
150 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSV file parsing thru Java 13 54
collection output issue 9 96
web project error add remove 1 85
Java 8 to Java 6 8 44
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.
Suggested Courses

752 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