Forums Register Login

Performance and JSP include...

+Pie Number of slices to send: Send
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"%>
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
https://coderanch.com/t/351594/Servlets/java/passing-parameters-included-jsp-file
[ May 01, 2002: Message edited by: Mike Curwen ]
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Cheers Mike.
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1578 times.
Similar Threads
Adding jquery to a page
Simple Question
JSP Include tag problem
Problem with "HTTPUnit with JavaScript"
How do i pass values to a javascript file
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:28:03.