aspose file tools*
The moose likes JSP and the fly likes Performance and JSP include... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Performance and JSP include..." Watch "Performance and JSP include..." New topic
Author

Performance and JSP include...

Gabriel Fox
Ranch Hand

Joined: Oct 17, 2001
Posts: 170
What is the difference in functionality and which gives a higher
performance between this two (i.e. including a JSP containing HTML code and JavaScript
functions and including an html page containing HTML code and JavaScript
functions) ;

<%@ include file="TestHTML.html"%>

<%@ include file="TestHTML.jsp"%>
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
If I were to do it...I would test it by including it about a hundred times (seperately) in a JSP. For this test JSP, first print the time, then add the hundred includes, then print the time.
Unfortunately, includeing HTML fails in the Tomcat 4.0*. We had a discussion on this issue in the SCWCD forum. I haven't tried it since.
regds.
- madhav


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
It would seem to me Gabriel that the include for the jsp has to be more expensive as the jsp needs to be compiled into a servlet and then after that needs to be included while as the html can be included as a static text file......
I hope that makes sense.....
Sahil


Adios
Gabriel Fox
Ranch Hand

Joined: Oct 17, 2001
Posts: 170
Hi Madhav , i will try playing around with your logic . Besides,it's nice knowing that
including an html page does not work with Tomcat 4.0 . I am interested in this since it
worked im Tomcat 3.2.1 which i'm using locally,but the application will be deployed on
Tomcat 4.0.
Sandy, U are very right. I tried organising my JSPs by factoring out all JavaScript
functions in a XXXX.js file and include in any desired page using
<Script src='asd.js'></Script> but this did not work.
Well , if we can discuss this further all ideas are welcomed.
Madhav , how do i get to the discussion on including html in JSP and Tomcat 4.0.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

The performance hit of doing the include is only incurred once though, for either of those.

Yes, the included jsp would need to be compiled, and then included, whereas the HTML would merely be included. But for both of the files, this only happens once.

If you were to use the <%@ include page="foo.*" %> syntax, then this would be included every time the page is called, and is thus more performance intensive. Additionaly, the jsp is recompiled each time it's included. So using <%@ would make any performance hit attributable to the jsp much more obvious.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Gabriel, I'll address something you made in your last post:

Try putting all your javascript in a single .js file and using the static include. (this one: <%@ ). I do this for css style sheets, and it works fine.

I'm not sure why people had trouble with including html files in Tomcat 4.x It works for me.

If you go into Tomcat's example directory:
webapps/example/jsp/include/include.jsp

and add the following to the bottom of the file:

You will see that both <%@ and <jsp:include works for both JSP and HTML content.

Also, check out this very old link about the differences between the two includes.
http://www.coderanch.com/t/351594/Servlets/java/passing-parameters-included-jsp-file
[ May 01, 2002: Message edited by: Mike Curwen ]
Gabriel Fox
Ranch Hand

Joined: Oct 17, 2001
Posts: 170
Hi Mike, i just want to clarify this by : <Script src='asd.js'></Script> , by asd.js i was refering to a java-script
file though that was a digression. But, do U reckon that instead of trying : <Script src='asd.js'></Script>
that i can as well use : <%@ file="includedJavaScriptFunctionsPage.jsp" %>
By the second i mean sticking all my Javascript functions in a JSP and including when needed.
Cheers Mike, i have printed the link resource U gave.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

You don't need to "wrap" your javascript into a JSP page.

Use the JSP include directive to include any static resources, such as html footers or headers, css style sheets, and files with javascript functions.
Gabriel Fox
Ranch Hand

Joined: Oct 17, 2001
Posts: 170
Cheers Mike.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Performance and JSP include...