includeFile
variables) Loading files dynamically
<% @include file= "/includes/<%=id%>/abc.html"%> This write system will be error, indicating that the file is not found, mainly because <%=id%> is not resolved to the ID you want.
OK, let's change the way, using <jsp:include page= "/includes/<%=id%>/adc.html" ></jsp:include> is not it possible. The colors shown in Eclipse <%=id%> tell us that this should be possible. But, I'm sorry, this is really not going to work.
So let's change our mind, we'll take the value behind the page as a variable and write it like this:
<%string add = "/includes/" + id+ "/abc.html"; %>
<jsp:include page= "<%=add%>" ></jsp:include>
It is possible to test this. In turn, you might think
<%string add = "/includes/" + id+ "/abc.html"; %>
<% @include file= "<%=add%>"%>
Whether or not, after testing, this is still not possible.
Turn from: http://hi.baidu.com/hankers/blog/item/dc1bda54489c215dd0090674.html
<%@ include file= ""%>
A static include file, that is, inserts the contained file at compile time. File cannot be a variable URL, nor can it take over any of the files specified by file, and the path referred to by file must be the path relative to the JSP Web page.
If you use <%@ include file= "common.jsp"%> in includebydirectives.jsp, the generated Includebydirectives_ Jsp.java will include the common.jsp file in the.
Note: In common.jsp, includebydirectives.jsp can reference mutually defined variables, methods. The directives defined in COMMON.JSP are merged into the includebydirectives.jsp.
<jsp:include page= ""/>
A dynamic include file, which is the result of running the include file at run time. Grammar:
<jsp:include page= "{urlspec | <%= expression%>}" flush= "true | False "/>
Or
<jsp:include page= "{urlspec | <%= expression%>}" flush= "true | False ">
<jsp:param name= "PN" value= "{PV | <%= expression%>}"/> *
</jsp:include>
If you use <jsp:include flush= "true" page= "common.jsp" ></jsp:include> in includebyaction.jsp; In the generated Includebyaction_jsp.java, a section is added to the include:
Org.apache.jasper.runtime.JspRuntimeLibrary.include (Request, Response, "common.jsp", out, true);
Note: includebyaction.jsp and common.jsp are independent of each other, includebyaction.jsp just add the results of common.jsp implementation.
For more detailed information, please refer to: http://hi.baidu.com/%D2%BB%C9%FA%CF%B7/blog/item/694657f378c5305c352accf2.html
JSP include file (variable) loading files dynamically