2

When i execute my application, i have an error.

The problem could not come from a wrong version of taglib ?

Error:

Caused by: javax.servlet.ServletException: javax.servlet.jsp.JspException: ServletException in 'menu.jsp': javax.servlet.jsp.JspException: Cannot create iterator for this collection

my menu is populate in my java application:

enter image description here

My JSP:

<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://struts.apache.org/tags-html-el" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean-el" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-logic-el" prefix="logic"%>
<%@ taglib tagdir="/WEB-INF/tags/" prefix="customTag"%>

<customTag:OverlayEntry id="overlaymenu" function="overlaymenu" />

<script type="text/javascript"
    src="<html:rewrite page="/javascript/jquery.easing.js"/>"></script>
<script type="text/javascript"
    src="<html:rewrite page="/javascript/jquery.accordion.js"/>"></script>
<link href="<html:rewrite page="/css/menu.css"/>" rel="stylesheet"
    type="text/css" />

<logic:present name="UserSession" property="menu">
        <ul id="navigation">
            <logic:iterate id="t" collection="${UserSession.menu.menuEntries}"
                indexId="idx">
                <customTag:MenuEntry
                    entry="<%=(com.sodifrance.apex.presentation.generic.session.MenuEntry) t%>" />
            </logic:iterate>
        </ul>
</logic:present>
<script type="text/javascript">
    jQuery('.current').parent().parent().prev('A').addClass('selected');
    jQuery('#navigation>li>A[href]').addClass('head2');

    jQuery('#navigation').Accordion({
        header : '.head',
        navigation : false,
        event : 'click',
        autoheight : false,
        animated : false,
        active : '.selected',
        selectedClass : 'selected',
        alwaysOpen : true
    });

    jQuery('#navigation>li>A.current').addClass('currentHead').removeClass(
            'current');
</script>

my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

    <display-name>APP</display-name>
    <description>Application</description>
    <filter>
        <filter-name>applicationFilter</filter-name>
        <filter-class>com.presentation.generic.security.ApplicationFilter</filter-class>
        <init-param>
            <param-name>exclusions</param-name>
            <param-value>/generic/authentification/Login.do,
                /generic/authentification/login_action.do,
                /generic/authentification/Disconnect.do,
                *.js,
                *.css,
                *.jpg,
                *.gif,
                *.png,
                *.ico
            </param-value>
        </init-param>
        <init-param>
            <param-name>loginUrl</param-name>
            <param-value>/generic/authentification/Login.do</param-value>
        </init-param>
    </filter>
    <filter>
        <filter-name>EncodingFilter</filter-name>
        <filter-class>com.presentation.generic.security.EncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>ISO-8859-15</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>applicationFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>EncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    <listener>
        <listener-class>com.presentation.generic.back.BirtEngineListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>2</param-value>
        </init-param>
        <init-param>
            <param-name>detail</param-name>
            <param-value>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>initDB</servlet-name>
        <servlet-class>com.metier.init.DbInitializerServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>
    <servlet>
        <servlet-name>birtEngineServlet</servlet-name>
        <servlet-class>com.report.generic.BirtServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
<!--    <servlet-mapping> -->
<!--        <servlet-name>jsp</servlet-name> -->
<!--        <url-pattern>/javascript/generic/messages.js</url-pattern> -->
<!--    </servlet-mapping> -->
<!--    <servlet-mapping> -->
<!--        <servlet-name>jsp</servlet-name> -->
<!--        <url-pattern>*.css</url-pattern> -->
<!--    </servlet-mapping> -->
    <servlet-mapping>
        <servlet-name>initDB</servlet-name>
        <url-pattern>/initDB</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

Action Class:

public ActionForward logInApplication_loginAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionForward actionForward = null; if (form != null) { LoginAction returnCode; LoginForm currentForm = (LoginForm) form; // execute code on exit of current page currentForm.onExit();

    UserSession session = null;
    AccueilForm accueilForm = new AccueilForm();

    if (validateLogin(currentForm, request)) {
        session = new UserSession();
        SessionHelper.getDefault().registerSession(session);

        initializeUserSession(currentForm, session);

        returnCode = LoginAction.LOGIN_SUCCESS;
    } else {
        ActionErrors e = new ActionErrors();
        e.add("property", new ActionMessage("authentification.Login.action.login.failed", Math.floor(Math.random() * 4)));
        addErrors(request, e);
        returnCode = LoginAction.LOGIN_FAIL;
    }

    switch (returnCode) {
        case LOGIN_FAIL:
            request.setAttribute(LoginForm.BEAN_NAME,currentForm);
            // execute code on entry of next page
            currentForm.onEntry();
            actionForward = mapping.findForward("LOGINACTION_LOGIN_FAIL");
            break;

        case LOGIN_SUCCESS:
            session.setLogin(currentForm.getLogin());
            request.getSession().setAttribute("UserSession", session);
            accueilForm.onEntry();
            request.setAttribute(AccueilForm.BEAN_NAME, accueilForm);
            actionForward = mapping.findForward("LOGINACTION_LOGIN_SUCCESS");
            break;

        default:
            break;
    }
}
return actionForward;

}

my configuration:

  • Tomcat 8
  • Struts 1.3.10
  • Jdk 1.8

1 Answer 1

1

The problem that you are using EL in the struts tag, that is not expecting it.

<logic:notEmpty name="UserSession" property="menu">
    <bean:define id="menuInfo" name="UserSession" property="menu"/>
    <ul id="navigation">
        <logic:iterate id="t" name="menuInfo" property="menuEntries" type="com.example.MenuEntry">
           ...
Sign up to request clarification or add additional context in comments.

13 Comments

when i do what you tell me i have this error: notEmpty tag in the tag library imported with prefix logic
you didn't import tag library, so you can't use it with jsp
Ok How librairie can I find it?
You can find them here. And you should read the answer before you accepted it the EL tags are generally unnecessary in today's server environments....
ok i add the library, but i have the same message error Cannot create iterator for this collection
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.