File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes jsp:include in a for loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:include in a for loop" Watch "jsp:include in a for loop" New topic
Author

jsp:include in a for loop

prabhat gupta
Greenhorn

Joined: Aug 21, 2001
Posts: 26
i am trying the following code :
<%
for(int i=0;i<filelist.length;i++){
%>
<jsp:include page="../com/prod/<%= filelist[i]%>" flush="true" />
<%
}
%>
Here i want to know that will the above code run successfully.
What I want the jsp to do is run through the array of file names and include them in the response page.
If this code cannot do the trick than i think the other alternative will be to get a BufferedReader read strings from the file and send those through out.println() method.the included files are static html files.
Give me your suggestions and code if possible, please,
IT'S URGENT.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

The support for dynamic includes is vendor specific (ie it can change from product to product and even between versions) but if you have a look at the JSP Technology Syntax, the valid syntax for a JSP include is

Why is this important? It menas that this should be valid, whereas your code is not... (doesn't promise it will work tho)


Dave
prabhat gupta
Greenhorn

Joined: Aug 21, 2001
Posts: 26
Still the html page is not included in the response.ie i want the content of the included html page to be displayed in the response page.I just want to incorporate some html formatted text present in those pages in the response.The jsp is still not doing that but yet runs successfully.
should i shift to the other alternative ie of bufferedReader.I have tried code on it and it works fine.Will this slow down the server response.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:include in a for loop
 
Similar Threads
JSP file location in a directory hierarchy
Include directive
Problem in accessing request object in child frames.
variable access in jSP
How do I access a value in an include from a parent jsp