0

I am using NetBeans 8.1 with the Spring framework and have stumbled on something I do not understand in relation too jsp:include and %@include and how it effects the availability or functionality of %@taglib entries.

I have this line at the top of my layout jsp that then includes my views.

 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

I am using this line to include my views to allow a layout to be used with more than on view.

  <jsp:include page="../views/${pa}.jsp"/>

In the view jsp I have the following code retrieving data from the database to create a drop down.

 <% List r = new com.mycompany.dbobjects.javaobject().main();%>
 <c:set var="n" value="<%=r%>"/>       
 <c:forEach items="${n}" var="item">
     <c:out value="${item.getID()}"/>
     <c:out value="${item.getName()}"/> 
 </c:forEach>

In order to get the data to appear using the jsp:include I have to add this line to the top of the view.

 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

If I use a %@include and hard code the view name I do not need to put the %@taglib at the top of the view. Being new to JSP and Java I do not understand why the two includes change the placement of the %@taglib line.

dutchlab
  • 541
  • 1
  • 13
  • 27
  • 1
    Have looked at this: http://stackoverflow.com/questions/14580120/whats-the-difference-between-including-files-with-jsp-include-directive-jsp-in? – Bogdan Sep 26 '16 at 17:03
  • Perfect. I did not see that one. Apparently I was not searching for the right terminology. – dutchlab Sep 26 '16 at 17:06

0 Answers0