2

I'm using eclipse to implement with the native Struts and hybernate support an application to display a series of links in a page. I'm getting the error:

javax.servlet.jsp.JspException: Cannot find bean: "ListeActeur" in scope: "session"

I've checked a lot of sites and forums, and nothing seems to fix this.

My struts-config:

<struts-config>
<form-beans type="org.apache.struts.action.ActionFormBean">
  <form-bean name="ListeActeur" type="mesForms.strust.ListeActeur"/>
  <form-bean name="vérifCritère" type="mesForms.strust.vérifCritère"/>
</form-beans>
<action-mapping>
    </action>   
    <action path="/Liste" 
    parameter="/vue/Invitation.jsp"
    name="ListeActeur     scope="request       validate="false"
                     type="mesAction.struts.ListeActeurAction">  
    <forward name="s" path="/vue/NewFile.jsp" redirect="false" /> 
    </action>
</action-mappings>
</struts-config>

ListeActeurAction:

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest req, HttpServletResponse res) throws Exception {
        System.out.println("Action");

        ListeActeur ListeActeur= (ListeActeur) form;
        String query = "select * from Acteur " ;

        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
         Iterator results = session.createSQLQuery(query).list().iterator();
         List <Acteur> lis = new ArrayList<Acteur>();
         while((results.hasNext()))
         {
             Acteur gg =new Acteur();
            Object[] row = (Object[]) results.next();
            gg.setActeurId((Integer)row[0]);
            gg.setNomActeur((String)row[2]);

             lis.add(gg);
         }
         req.getSession(true).setAttribute("lis", lis);
         session.getTransaction().commit();
         HibernateUtil.getSessionFactory().close();             
        ListeActeur.setLis( lis);
        req.setAttribute("formu", ListeActeur.getLis());

        return mapping.findForward("s");
        }
}

ListeActeur:

public class ListeActeur extends ActionForm {

private  List <Acteur> lis=null;

public List <Acteur> getLis(){
    return lis;}
public void setLis(List <Acteur> lis){this.lis=lis;}
public void reset(ActionMapping mapping, HttpServletRequest request) { 

    lis = new ArrayList<Acteur>();  
}

I really dont know what to do. Im a newbie in Struts.Thanks in advance!

Michael C. O'Connor
  • 9,742
  • 3
  • 37
  • 49
toutou
  • 61
  • 2
  • 6
  • 12

1 Answers1

3

You have

<action path="/Liste" scope="request" .../>

and

<logic:iterate ... scope="session" >

no wonder you get this exception. If you configure Struts to store the form bean in the request, don't try to fetch it from the session in your JSP.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • yes thank you ,i have an other problem : jsp page always displays an empty list even though my list is not empty please help me – toutou May 27 '12 at 18:08
  • You enclosed the logic:iterate inside a logic:empty tag. This means that you iterate only if the list is empty. – JB Nizet May 27 '12 at 18:15
  • I remove the tag ligic: empty, but the same problem it displays a blank page even table it does not display,Here is the code of page
    Nom Acteur:
    Adresse IP :
    – toutou May 27 '12 at 18:41
  • I infer that it does not access the class LsiteActeurAction and I don't know why,pleaseee help mee – toutou May 27 '12 at 19:15