jorj
asked on
jsp:include page="dynamic name.html"
I have pieces of html files in a folder and I want them included inside a jsp with a jsp:include directive. Preciselly, I have a number of files named file100.htm, file101.htm... and I receive an id as parameter when someone access my jsp page : id=101. Inside the jsp page I need to send some data to the client before AND after the inclusion statement so I would need something like this:
<jsp:include page="file<%=id%>.htm"/>
Do I have chances to manage somehow this problem ?
Thank you.
<jsp:include page="file<%=id%>.htm"/>
Do I have chances to manage somehow this problem ?
Thank you.
for example if your file is called include.jsp
the call is:
include.jsp?id=101
your code will look like:
<% String id = request.getParameter("id") ;
if ((id != null) and (id.length() > 0)) { %>
<jsp:include page="file<%=id%>.htm" flush="true" />
<% }
else { %>
No ID parameter!!
<% } %>
the call is:
include.jsp?id=101
your code will look like:
<% String id = request.getParameter("id")
if ((id != null) and (id.length() > 0)) { %>
<jsp:include page="file<%=id%>.htm" flush="true" />
<% }
else { %>
No ID parameter!!
<% } %>
ASKER
no, wrong answer. I don't know what JSP engine you use but mine doesn't allow this. In the meantime I found the answer so I have to close this question with no winner.
Sorry about that but believe me I first tested the method you proposed and only after I posted the question here.
Anyway, the answer is:
<%pageContext.include("fil e" + id + ".html");%>
I found it by looking into the java code resulted after jsp file was proceessed.
Sorry about that but believe me I first tested the method you proposed and only after I posted the question here.
Anyway, the answer is:
<%pageContext.include("fil
I found it by looking into the java code resulted after jsp file was proceessed.
ASKER
re-post last comments:
no, wrong answer. I don't know what JSP engine you use but mine doesn't allow this. In the meantime
I found the answer so I have to close this question with no winner.
Sorry about that but believe me I first tested the method you proposed and only after I posted the question
here.
Anyway, the answer is:
<%pageContext.include("fil e" + id + ".html");%>
I found it by looking into the java code resulted after jsp file was proceessed.
no, wrong answer. I don't know what JSP engine you use but mine doesn't allow this. In the meantime
I found the answer so I have to close this question with no winner.
Sorry about that but believe me I first tested the method you proposed and only after I posted the question
here.
Anyway, the answer is:
<%pageContext.include("fil
I found it by looking into the java code resulted after jsp file was proceessed.
ASKER
re-post last comments:
no, wrong answer. I don't know what JSP engine you use but mine doesn't allow this. In the meantime
I found the answer so I have to close this question with no winner.
Sorry about that but believe me I first tested the method you proposed and only after I posted the question
here.
Anyway, the answer is:
<%pageContext.include("fil e" + id + ".html");%>
I found it by looking into the java code resulted after jsp file was proceessed.
no, wrong answer. I don't know what JSP engine you use but mine doesn't allow this. In the meantime
I found the answer so I have to close this question with no winner.
Sorry about that but believe me I first tested the method you proposed and only after I posted the question
here.
Anyway, the answer is:
<%pageContext.include("fil
I found it by looking into the java code resulted after jsp file was proceessed.
ASKER
re-post last comments:
no, wrong answer. I don't know what JSP engine you use but mine doesn't allow this. In the meantime
I found the answer so I have to close this question with no winner.
Sorry about that but believe me I first tested the method you proposed and only after I posted the question
here.
Anyway, the answer is:
<%pageContext.include("fil e" + id + ".html");%>
I found it by looking into the java code resulted after jsp file was proceessed.
no, wrong answer. I don't know what JSP engine you use but mine doesn't allow this. In the meantime
I found the answer so I have to close this question with no winner.
Sorry about that but believe me I first tested the method you proposed and only after I posted the question
here.
Anyway, the answer is:
<%pageContext.include("fil
I found it by looking into the java code resulted after jsp file was proceessed.
that is what JSP include in converted into.. by the servlet engine!
I am not wrong.. look at Sun's documentation of JSP 1.1:
http://java.sun.com/products/jsp/tags/11/syntaxref1112.html
I am not wrong.. look at Sun's documentation of JSP 1.1:
http://java.sun.com/products/jsp/tags/11/syntaxref1112.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, I believe you are right. I am going to reward you.
Thank you.
Thank you.
<jsp:include page="<%= varname %>" flush="true" />
or
<jsp:include page="file<%=id%>.htm" flush="true" />
Static includes directives are preprocessed before scripting code executes so you cannot use variables
there.
CJ