wood burning stoves 2.0
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
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:include in a for loop" Watch "jsp:include in a for loop" New topic

jsp:include in a for loop

prabhat gupta

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,
David O'Meara

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)

prabhat gupta

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
It's not a secret anymore!