You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jonathan Mast <jh...@gmail.com> on 2008/06/03 18:52:27 UTC

versus <% include %>

I'm wondering if the <%@ include file="somefile.jsp" %> method of including
a file is more error prone (on Tomcat) than <jsp:include page="somefile.jsp"
flush="true"/> approach?

Any ideas would helpful, especially an explanation of what is being done
under the hood when these 2 mechanisms are being invoked.

Tomcat 5.5
Java 1.4.2

Thanks

Re: versus <% include %>

Posted by Bill Davidson <bi...@seatadvisor.com>.
Jim Cox wrote:
> That's not really what I see here.
>
> I think of <%@ include="file"%> directives as akin to a C compiler's
> #include, or a shell's "source", directive in that the content of the file
> is interpreted as if it were directly typed into the containing file. On the
> old-ish version of Tomcat that I have, changes to the included file are
> picked up automatically (i.e. no need to "force" a recompile).
>   
When I last tried testing this, it was with Sun Java System Application 
Server
and it was a while back.  It didn't recompile if the included file 
changed.  I'll
have to try it with a recent version of Tomcat when I get a chance.  
According
to what you're saying, Tomcat is smart enough to notice that include 
files have
changed.
> I think of <jsp:include page="relative url"> directives as essentially
> making an HTTP request and including the output at the point of the tag
> (though the analogy isn't quite perfect). It's been my experience that the
> page included via jsp:include can be static HTML or a
> dynamically-interpreted JSP page.
>   
Maybe it was that I was including files with extension ".jspf" since I 
considered
them to be fragments, and not full JSP's.  I guess I should be thinking 
of them as
full JSP's instead.  Would they therefore have their own request/page scope
separate from the page including including them?  I guess as long as I'm 
only
using session data, it might be OK.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: versus <% include %>

Posted by Jim Cox <sh...@gmail.com>.
That's not really what I see here.

I think of <%@ include="file"%> directives as akin to a C compiler's
#include, or a shell's "source", directive in that the content of the file
is interpreted as if it were directly typed into the containing file. On the
old-ish version of Tomcat that I have, changes to the included file are
picked up automatically (i.e. no need to "force" a recompile).

I think of <jsp:include page="relative url"> directives as essentially
making an HTTP request and including the output at the point of the tag
(though the analogy isn't quite perfect). It's been my experience that the
page included via jsp:include can be static HTML or a
dynamically-interpreted JSP page.

For example, try the following:

test@zest$ cat test.inc
<%!
  int the_number_in_test_inc = 1 ;
%>

test@zest$ cat test-inc.jsp
The value passed to test-inc.jsp was
<%=request.getParameter("for-test-inc")%>

test@zest$ cat test.jsp
<%@ include file="test.inc" %>
The number in test.inc is <%=the_number_in_test_inc%>

<jsp:include flush="true" page="test-inc.jsp">
  <jsp:param name="for-test-inc" value="9999"/>
</jsp:include>

test@zest$ wget http://localhost/voxis/test.jsp
The number in test.inc is 1
The value passed to test-inc.jsp was 9999

# ...change test.inc to see if we get auto-recompile
test@zest$ cat test.inc
<%!
  int the_number_in_test_inc = 1000 ;
%>

test@zest$ wget http://localhost/voxis/test.jsp
The number in test.inc is 1000
The value passed to test-inc.jsp was 9999




On Thu, Jun 5, 2008 at 4:50 PM, Bill Davidson <bi...@seatadvisor.com> wrote:

> Bill Davidson wrote:
>
>> <%@include ... %> happens at compile time.  That is, only the first
>> time the JSP page is loaded.  The included data ends up in the compiled
>> servlet.  It has been my experience that you can have other JSP directives
>> in the included file and they will be properly interpreted.
>>
> I forgot to add, if the included file changes, then the JSP will not
> reflect
> that change unless you force it to be recompiled.
>
>> <jsp:include ... /> happens at run time, every time the JSP page is
>> loaded.  The included data is not compiled into the servlet, rather
>> the generated servlet has code to re-read the included file every time
>> it runs.  It has been my experience that JSP tags in the included file
>> will not be interpreted so you're pretty much limited to HTML (or whatever
>> your final output format to the user agent is) in the included file.
>>
> In this case, if the included file changes, the JSP should reflect the
> changes on the next page load, without a recompile.
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: versus <% include %>

Posted by Bill Davidson <bi...@seatadvisor.com>.
Bill Davidson wrote:
> <%@include ... %> happens at compile time.  That is, only the first
> time the JSP page is loaded.  The included data ends up in the compiled
> servlet.  It has been my experience that you can have other JSP 
> directives
> in the included file and they will be properly interpreted.
I forgot to add, if the included file changes, then the JSP will not reflect
that change unless you force it to be recompiled.
> <jsp:include ... /> happens at run time, every time the JSP page is
> loaded.  The included data is not compiled into the servlet, rather
> the generated servlet has code to re-read the included file every time
> it runs.  It has been my experience that JSP tags in the included file
> will not be interpreted so you're pretty much limited to HTML (or 
> whatever
> your final output format to the user agent is) in the included file.
In this case, if the included file changes, the JSP should reflect the
changes on the next page load, without a recompile.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: versus <% include %>

Posted by Bill Davidson <bi...@seatadvisor.com>.
Andrei Tchijov wrote:
> they are identical. you will want to use <jsp:include> if you care to 
> have your JSP pages in form of valid XML.
They are most definitely not identical.

<%@include ... %> happens at compile time.  That is, only the first
time the JSP page is loaded.  The included data ends up in the compiled
servlet.  It has been my experience that you can have other JSP directives
in the included file and they will be properly interpreted.

<jsp:include ... /> happens at run time, every time the JSP page is
loaded.  The included data is not compiled into the servlet, rather
the generated servlet has code to re-read the included file every time
it runs.  It has been my experience that JSP tags in the included file
will not be interpreted so you're pretty much limited to HTML (or whatever
your final output format to the user agent is) in the included file.



Re: versus <% include %>

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
----- Original Message ----- 
From: "Rogelio R. Vizcaino L." <rv...@quarksoft.net>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, June 03, 2008 7:35 PM
Subject: Re: <jsp:include> versus <% include %>


> One is static (translation time) the other dynamic (runtime).
> http://tinman.cs.gsu.edu/~raj/oracle10/web.1013/b14430/workjsp.htm

Nice little Tut that, thanks
Another one as well
http://www.ibm.com/developerworks/java/library/j-jsp04293.html
and Suns blurb
http://java.sun.com/products/jsp/syntax/1.2/syntaxref129.html
http://java.sun.com/products/jsp/syntax/1.2/syntaxref1214.html


---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: versus <% include %>

Posted by "Rogelio R. Vizcaino L." <rv...@quarksoft.net>.
One is static (translation time) the other dynamic (runtime).
http://tinman.cs.gsu.edu/~raj/oracle10/web.1013/b14430/workjsp.htm


On Jun 3, 2008, at 12:21 PM, Jonathan Mast wrote:

> I don't think they are exactly the same.  I had something that was not
> working with <jsp:include> but did for <%@ include %>.
>
> I understand <jsp:...> this the new, XML-complaint way to do  
> things, but
> there must be subtle differences in how things are being done  
> between these
> 2 approaches.
>
> On Tue, Jun 3, 2008 at 1:07 PM, Andrei Tchijov <an...@tchijov.com>  
> wrote:
>
>> they are identical. you will want to use <jsp:include> if you care  
>> to have
>> your JSP pages in form of valid XML.
>>
>>
>> On Jun 3, 2008, at 12:52 , Jonathan Mast wrote:
>>
>>  I'm wondering if the <%@ include file="somefile.jsp" %> method of
>>> including
>>> a file is more error prone (on Tomcat) than <jsp:include
>>> page="somefile.jsp"
>>> flush="true"/> approach?
>>>
>>> Any ideas would helpful, especially an explanation of what is  
>>> being done
>>> under the hood when these 2 mechanisms are being invoked.
>>>
>>> Tomcat 5.5
>>> Java 1.4.2
>>>
>>> Thanks
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>


Re: versus <% include %>

Posted by Jonathan Mast <jh...@gmail.com>.
I don't think they are exactly the same.  I had something that was not
working with <jsp:include> but did for <%@ include %>.

I understand <jsp:...> this the new, XML-complaint way to do things, but
there must be subtle differences in how things are being done between these
2 approaches.

On Tue, Jun 3, 2008 at 1:07 PM, Andrei Tchijov <an...@tchijov.com> wrote:

> they are identical. you will want to use <jsp:include> if you care to have
> your JSP pages in form of valid XML.
>
>
> On Jun 3, 2008, at 12:52 , Jonathan Mast wrote:
>
>  I'm wondering if the <%@ include file="somefile.jsp" %> method of
>> including
>> a file is more error prone (on Tomcat) than <jsp:include
>> page="somefile.jsp"
>> flush="true"/> approach?
>>
>> Any ideas would helpful, especially an explanation of what is being done
>> under the hood when these 2 mechanisms are being invoked.
>>
>> Tomcat 5.5
>> Java 1.4.2
>>
>> Thanks
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: versus <% include %>

Posted by Andrei Tchijov <an...@tchijov.com>.
they are identical. you will want to use <jsp:include> if you care to  
have your JSP pages in form of valid XML.

On Jun 3, 2008, at 12:52 , Jonathan Mast wrote:

> I'm wondering if the <%@ include file="somefile.jsp" %> method of  
> including
> a file is more error prone (on Tomcat) than <jsp:include  
> page="somefile.jsp"
> flush="true"/> approach?
>
> Any ideas would helpful, especially an explanation of what is being  
> done
> under the hood when these 2 mechanisms are being invoked.
>
> Tomcat 5.5
> Java 1.4.2
>
> Thanks


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: versus <% include %>

Posted by Andrei Tchijov <an...@tchijov.com>.
Never knew that they are different.  But they most certainly are.  
Below is straight from the document you have referred.



On Jun 3, 2008, at 13:36 , Hassan Schroeder wrote:

> On Tue, Jun 3, 2008 at 9:52 AM, Jonathan Mast
> <jh...@gmail.com> wrote:
>> I'm wondering if the <%@ include file="somefile.jsp" %> method of  
>> including
>> a file is more error prone (on Tomcat) than <jsp:include  
>> page="somefile.jsp"
>> flush="true"/> approach?
>>
>> Any ideas would helpful, especially an explanation of what is being  
>> done
>> under the hood when these 2 mechanisms are being invoked.
>
> "error prone"? Dunno about that, but you can read the differences
> between the two (and yes, they are different) in the JSP Spec -- it's
> section JSP1.10.3 in the 2.1 spec document.
>
> HTH,
> -- 
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


Re: versus <% include %>

Posted by Hassan Schroeder <ha...@gmail.com>.
On Tue, Jun 3, 2008 at 9:52 AM, Jonathan Mast
<jh...@gmail.com> wrote:
> I'm wondering if the <%@ include file="somefile.jsp" %> method of including
> a file is more error prone (on Tomcat) than <jsp:include page="somefile.jsp"
> flush="true"/> approach?
>
> Any ideas would helpful, especially an explanation of what is being done
> under the hood when these 2 mechanisms are being invoked.

"error prone"? Dunno about that, but you can read the differences
between the two (and yes, they are different) in the JSP Spec -- it's
section JSP1.10.3 in the 2.1 spec document.

HTH,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org