Meaningless Drivel is fun!*
The moose likes JSP and the fly likes About JSP performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "About JSP performance" Watch "About JSP performance" New topic
Author

About JSP performance

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Hi all,
Is it bad to have too many jsps in a web app since every single jsp gets converted to a servlet. More jsps will create many servlet
instances.
Thanks in adv.


Groovy
Ryan Bailey
Ranch Hand

Joined: Feb 26, 2002
Posts: 134
It is not bad to have a lot of JSPs. During translation time every JSP is converted to a servlet. This servlet is then loaded into memory and instantiated when requested. Only one servlet instance will be loaded per servlet(jsp) on the Container unless you are implementing the SingleThreadModel.
Hope this helps.
Cheers,
Ryan


SCJP 1.4, SCWCD
Java: The power, elegance, and simplicity of a hand grenade
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Suppose I access all the pages of a web app then many servlet instances(= # of JSP's) are created.
If I use jsp:include tags in my pages there will be more jsps which means more servlet instances.
Does it mean to say that avoiding jsp:include (by replacing jsp:include tag by the code of the pages refered by jsp:include )is better?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61447
    
  67

My opinion would be to use as many JSPs as makes sense for the structure of your application without worrying about the number. It is unlikely that the number of servlets in your app is the cause of performance problems (if any).
Is this an academic exercise, or are you actually trying to track down a performance issue?
bear
[ May 06, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ryan Bailey
Ranch Hand

Joined: Feb 26, 2002
Posts: 134
Once you create a servlet instance for a class, there will NEVER be more than one servlet instance for that particular class. That is, unless you implement the SingleThreadModel. If you are accessing X pages then there will never be more than X + 0 instances.
Does this make sense?
I personally follow the MVC design pattern. The only time I use a JSP page is for the presentation layer of my program. I never include business logic in a JSP.
Cheers,
Ryan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: About JSP performance