tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Cox" <shakahsha...@gmail.com>
Subject Re: <jsp:include> versus <% include %>
Date Thu, 05 Jun 2008 21:31:32 GMT
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 <billd@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
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message