Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB connections

 
suman deb
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why DB connections are not written directly in JSPs ?
(a) Response is slow
(b) Not a standard J2EE architecture
(c) Load Balancing is not possible
(d) All the above
(e) Both (b) and (c)
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(e) both (b) and (c)
 
Ram kovis
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David

Thats intersting .. I know that its not a standard J2EE architure.. as maintaince of the applcaiton will be a problem..But I would like to know , how this affect Load balancing . Could you please elborate?

Thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suman,
Is this question from anywhere? Like a mock exam?

I agree with David. If you have your database access behind an EJB layer, it can be load balanced. A JSP cannot.

I would add an expansion of b that is really poor design, breaks MVC and is extremely difficult to maintain.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would add that anyone who obtains a JDBC Connection in a JSP is likely to also start a transaction from that JSP. This is really poor as client applications are subject to interruptions or unexpected terminations. If you start and stop a transaction at the client level, you risk:

- Consumption of network resources during waits for user actions or interruptions until resumption of client activity or timeout.

- Consumption of processing resources and network resources to rollback the transaction after timeout or termination of the transaction.

In almost every case, transactions should be started in the Data Storage or Business Logic layer.
 
vikassheel gupta
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
because in J2ee there is a concept of connection pooling and with the help of that we maintain balancing so i think b and c is the right answer
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP is a part of View in MVC design pattern and View is not responsible for backend operations. Try to imagine that you will change the DB server.

Load balancing is dependent on application server vendor. Best option is use app server connection pool. Than you don't need to care how servers will do this load balancing.
 
Anand Karia
Ranch Hand
Posts: 156
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I also agreed with David Ulicny.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have your database access behind an EJB layer, it can be load balanced. A JSP cannot.

It is possible to load balance JSPs (and servlets). For instance, BEA has its Recommended Multi-Tier Architecture which comprises a load balancer in front of two separate WebLogic Server clusters: one to serve static HTTP content and clustered servlets, and one to serve clustered EJBs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic