Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Model 2 Architecture of JSP

Posted on 2000-05-12
3
Medium Priority
?
156 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 225 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

Google Certified Professional - Cloud Architect

This course (1 of 3) is designed to help students who are interested in Google Cloud Platform (GCP) to become familiar with the platform, navigate the console and learn its capabilities. It will also prepare students for the Google Cloud Architect certification exam.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

721 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