This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Include file dynamically  RSS feed

 
Noga Erez
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to use include tag in a loop, and to include different file every time.
I have list of String in my form:

form.serviceList

This is my code:

<c:forEach items="${form.serviceList}" var="service">
<%@ include file="${service}" %>
</c:forEach>

However I get the exception:
File "/services/${service}" not found.

What should I do?

Thanks.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you cant use dynamic value in file attribute of @include . but you can pass dynamic value to page attribute of jsp:include .because the first one include another jsp at translation time and later one include at runtime.
<edit>I encourage you to use <c: import url="..."/> tag of jstl</edit>
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch
 
Noga Erez
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
I changed it to use jsp:include and it works.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!