1 Answer
1

What's the difference? Primarily <jsp:include> inserts the contents of another JSP page within the same JAR relative to the current page whereas <c:import> can read in an absolute or relative URL and display those contents on the page, retrieve a Reader or store the contents in a variable.

+1. Looking at the docs, it does appear that <jsp:include> will do what the OP is asking for; however, it does not appear to be completely analogous to PHP's include(). Notably, the included file does not share the same global scope; functions/classes created by the included file won't become available in the including script, etc. Instead, it executes the included script, and returns the output.
–
Frank FarmerJan 13 '10 at 4:23

Where's your vote, Frank? I did the first upvote, but I don't see a second one :)
–
BalusCJan 13 '10 at 11:15

Thanks, so the example I have above is the proper syntax?
–
user110241Jan 13 '10 at 23:56

@devils-avacado: yes. @cletus' edit: the actual difference between jsp:include and c:import is that the first includes the source and that the second includes the output (apart from having the possiblity to get it from an external URL).
–
BalusCJan 14 '10 at 2:03

1

The included document is arbitrary so it could be CSS, Javascript or HTML ie what you could normally have in an HTML document.
–
cletusJan 14 '10 at 16:18