1

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">
  1. I have the taglibs uri configured and it works well, since the tags are being processed.
  2. This worked with Spring 3.0.7 & servlet 2.3. Now, we are migrating to spring 4.0.6 & servlet 2.3.
  3. On the other post, the requester used servlet 2.5 and still faced the issue. Migrating to servlet 2.5 would be a huge impact on our application.

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.

Community
  • 1
  • 1
Vikap
  • 25
  • 4
  • 1
    As per its documentation, Spring 4 requires a minimum of Servlet 2.5. Why are you trying to get it to run on Servlet 2.3? The technical explanation is, since Servlet 2.4, EL API has moved from JSTL to JSP. So Spring tags wouldn't expect to find EL API in JSTL, but in JSP. However, as you're still on Servlet 2.3, it isn't there in JSP yet. – BalusC Aug 10 '15 at 13:19
  • @BalusC Thanks for responding to my post. We started the migration without (for some reason) realizing the recommendation to migrate to servlet 2.5 and now the change would be of huge impact on the application. As you mention, with servlet 2.4, the EL parsing has moved out of JSTL and in JSP. Even if we migrate to servlet 2.5, the syntax remains the same for
    tag. What has changed that is causing this issue? The rest of the application works well wherever there is no
    tag. Please excuse if I have failed to grasp your point and kindly elaborate if so.
    – Vikap Aug 10 '15 at 14:29
  • I am still stuck on the issue. Could someone provide me with pointers? @BalusC If possible, Could you please find some time to clarify? – Vikap Aug 14 '15 at 07:47
  • Just use a Spring version compatible with target Servlet version. Better first upgrade Servlet version and then Spring. – BalusC Aug 14 '15 at 07:57
  • @BalusC I finally made the changes as suggested by you and migrated my servlet version and it solved my problem. If impacts my legacy code at other places but those I will adapt. Thanks for your input. If you can move your comment to an answer, I can accept that. – Vikap Aug 24 '15 at 09:37

1 Answers1

0

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.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555