Hello people, i would like to know how to call a JSP-file with different parameters so that I can use it as a blueprint for several webpages in my project. My project is quite simple and only for learning purposes: I have a start page with several cooking recipes. If I click on one of those recipes I will get a detailed view of the recipe, which includes some text and an image. However, I don't want to create a new jsp-file for every recipe, because all recipes have the same layout. Instead, I want to use one and the same jsp-file for an arbitrary amount of recipes. The content of those recipes should be located in one or several XML-files. I couldn't find a good example on the internet, so I would be very happy if someone could help me here.
You can only invoke methods with arguments in EL if you're targeting and running a Servlet 3.0 compatible container (e.g. Tomcat 7, Glassfish 3, JBoss AS 6, etc) with a web.xml declared conform Servlet 3.0. This servlet version comes along with EL 2.2 which allows invoking arbitrary instance methods with arguments. Assuming that you've a ${bean} in the scope which refers to an instance of a class which has a method something like public Object[] getArray(String key), then you should be able to do this: <c:forEach items="${bean.getArray('foo')}" var="item"> ${item} <br /> </c:forEach> or even with another variable as argument <c:forEach items="${bean.getArray(foo)}" var="item"> ${item} <br /> </c:forEach>