*
The moose likes Servlets and the fly likes Performance: MVC versus Single JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Performance: MVC versus Single JSP" Watch "Performance: MVC versus Single JSP" New topic
Author

Performance: MVC versus Single JSP

Bruno Collins
Greenhorn

Joined: Nov 30, 2001
Posts: 19
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

Joined: Jun 25, 2001
Posts: 16019
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Zac Roberts
Ranch Hand

Joined: Jan 29, 2002
Posts: 82
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?


Zac Roberts<br />SCJP2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Performance: MVC versus Single JSP