Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why DB connections are not written directly in JSPs ?

 
Sim Kim
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Reasons :
a)Response is slow
b) Not a standard J2EE architecture
c) Load Balancing is not possible

Which one is correct ?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lavjeet,
Whenever someone enters multiple choice questions into a forum, my first assumption is that they have copied and pasted from a homework assignment.

Which do you think it is?
Why?
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it's homework, I mean, what with a 95% on the SCJP!
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like homework to me too... but I will give it a shot anyway.

I tend to learn toward the fact that it is not standard J2EE architecture. I am a MVC Model 2 advocate, and I maintain that a JSP should only be used as the view. The place for database logic is in the model. Also, let's remember that we should be using database connection pooling in a J2EE application anyway.

As far as the other two... Is the response slower if you code a database connection directly into the JSP? I doubt it because all JSPs are compiled into a servlet anyway, so they should be executed just as quickly (with the exception of thefirst time of course). I could be wrong though... if someone knows differently, I would be interested in their thoughts.

And what does load balancing have to do with it? I fail to see how distributing processing and communications activity evenly across a computer network will no longer be possible just because you put a database connection into a JSP...
[ November 22, 2005: Message edited by: Paul Bourdeaux ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic