do some thing like this:
<c:if test="<%= !allPortlets.isEmpty() && !layoutTypePortlet.hasStateMax() %>">
	<%
	StringBundler sb = new StringBundler(2 * allPortlets.size() - 1);
	for (int i = 0; i < allPortlets.size(); i++) {
		Portlet portletBean = allPortlets.get(i);

		String value = Portlet.PORTLET_ID_ACCESSOR.get(bean);

		if (value != null) {
			sb.append(HtmlUtil.escapeJS(value));
		}

		if ((i + 1) != allPortlets.size()) {
			sb.append("','");
		}
	}
	%>
	Liferay.Portlet.list = ['<%= sb.toString %>'];