We are migrating our application from spring 3 to spring 4. I now have a problem wherein the session variables gets resolved when I use c:out and not when I use form:form. I viewed a similar issue on another post which remained unanswered. But, I am now facing the same issue.
<%@ include file="/common/taglibs.jsp"%>
<c:forEach var="item" items="${yesNos}">
<c:out value="${item}"/>
</c:forEach>
<form:select path="blocked">
<form:option value="" label=""/>
<form:options items="${yesNos}" itemValue="id" itemLabel="${domainValueProperty}"/>
</form:select>
c:forEach is able to iterate on the list "yesNos". form:options cannot seem to identify this list "yesNos" and throws an error
OptionsTag - Type [java.lang.String] is not valid for option items
yesNos is a list of our POJO and has a corresponding PropertyEditor defined. I suspected PropertyEditor to be an issue but the below realization stumped me.
I also realized the form:form tag also shows an issue wherein the dynamic session variable passed to the action attribute does not get resolved and stays as ${} even on the generated HTML source.
JSP: formActionURL is of type String
<form:form action="${formActionURL}" commandName="pDSearch">
HTML source
<form id="pDSearch" action="${formActionURL}" method="post">
Below is the taglibs.jsp that is imported on the page
<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" %>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="security" %>
<%@ taglib uri="http://www.springmodules.org/tags/commons-validator" prefix="v" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display" %>
<%@ taglib uri="http://struts-menu.sf.net/tag-el" prefix="menu" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page"%>
Greatly appreciate if someone could redirect me to a source where I can find answer to my issue. Do let me know if you need further information.
The way how EL works has changed during the transition Servlet 2.3 --> Servlet 2.4.
During Servlet 2.3, EL was supplied as part of JSTL 1.0. Since Servlet 2.4, EL was supplied as part of JSP 2.0, and EL was removed from JSTL 1.1.
Any Servlet 2.4+ compatible JSP tag library, will expect to find EL in JSP, not in JSTL anymore. In other words, when you still use a Servlet 2.4+ compatible JSP tag library on a Servlet 2.3 container, then EL expressions in all its tags will stop working, because it can't find EL in JSP.
So, when you want to use a Servlet 2.4+ compatible JSP tag library, like Spring 4+, which actually requires Servlet 2.5, then you really need to upgrade to exactly that minimum Servlet version.