How to reuse object from JS and reuse back in the foreach taglib [duplicate]

1.Currently, i have 2 pieces of code. I need to pass filterFactory object below to foreach items in JSP. Im very new on this as this is my first time tackle JSP:

2.Is it possible in the taglib i can call the object, example: filterFactory.lineName

const lookupFilterLine = ${lookupFilterLine};
const filterFactory = lookupFilterLine.filter(function (x) {
                          return x.factoryName === factory;
                          });

output from filterFactory:
   {factoryName: 'TEST', type: 'line', lineName: 'This is line B'},
   {factoryName: 'TEST', type: 'line', lineName: 'This is line C'},
   {factoryName: 'TEST', type: 'line', lineName: 'This is line A'}

To below code:

$("#lineId").html('<c:forEach items="filterFactory" var="filterFactory">'
                    '<c:if test="${fn:contains(filterFactory, factory)}">'
                      +'<option value="${filterFactory}" label="${filterFactory}" />'
                     </c:if>'
                  +'</c:forEach>');