Solved

Model 2 Architecture of JSP

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ArrayIndexOutOfBoundException 9 83
java jdbc batch example 8 35
java stored proc example 9 32
How to determine if a string is a valid SHA value 7 34
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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 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:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

809 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