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

Performance: MVC versus Single JSP

 
Bruno Collins
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I code, lets say, retrieval from a database a list of records that match some criteria. I can do this basically one of two ways, a) Servlet that runs a query, populates a bean and then displays in a JSP -OR- b) do the lot in the JSP.
Which is faster? Does one consume significantly more resources than the other?
Let's ignore for the purpose of this post usual MVC benefits (maintenance & separation of duties etc).
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Typically you should see any performance differences from how the logic is broken out are minimal compared to the overhead of the network and database connections.
When the overhead for keeping things well-structured actually causes significant performance degradation in the server, it's probably time to consider a faster language than Java!
Finally, there's the cardinal rule for optimization: It's virtually ALWAYS easier to optimize a well-structured program than it is to debug an "optimized" one. Along with its corrollary: The bottleneck is almost NEVER where you "know" it is.
 
Zac Roberts
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am fairly new to server side java... are you saying that sometimes it is OK and won't hurt performance if you lump everything into the JSP, assuming maybe it is a very small app with not much worry about code maintanence?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic