File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Performance and JSP include...

 
Gabriel Fox
Ranch Hand
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5040
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
sandy gupta
Ranch Hand
Posts: 228
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Gabriel Fox
Ranch Hand
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Mike.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic