Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

more difference jsp:include vs. include directive

 
Yan Zhou
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having a hard time to use EL in include directive:

<%@ include file="static/files/${obj.directory}/page.html" %>

but using jsp:include works fine. Is that because include directive does not support EL in its argument? The following is fine with jsp:include.

<jsp:include page="static/files/${obj.directory}/page.html" />

Further, I also noticed that the directory where the container starts to search for the included file is different. For example,

with jsp:include page="/....", that means the file starts with the root of the web app. Without the beginning /, the file is relative to the JSP that includes it.

But with include directive, the beginning / will not direct a JSP to start search from the webapp's root directory. I only had success setting the path relative to current page that includes it.

Thanks.
Yan
[ January 04, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The inlcude directive is a translation-time mechanism, so how could it support the EL which relies upon run-time variables?
 
Yan Zhou
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that makes sense.
Thanks.
Yan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!