facebook

problem to get Arraylist from session in jsp

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #278532 Reply

    Figa
    Member

    I,
    I make a Web application with Struts.
    In the code of the actionBean I use a ArrayList<generic>.

    MenuAccess menuAccess = new MenuAccess();
    ArrayList<MenuAccess> menuArray = new ArrayList<MenuAccess>();
    menuArray.add(menuAccess);
    session.setAttribute(“menuArray”, menuArray);
    @SuppressWarnings(“unchecked”)
    ArrayList menuArray2 = (ArrayList<MenuAccess>) session.getAttribute(“menuArray”);
    for (int i = 0; i < menuArray2.size(); i++ ) {
    menuAccess = null;
    menuAccess = (MenuAccess)menuArray2.get(i);
    System.out.println(“ArrayList from session : ” + menuAccess.getName() );
    }
    after the actionBean, it’s ok the results is correct
    09:41:12,031 INFO [STDOUT] ArrayList from session : Inscription
    09:41:12,031 INFO [STDOUT] ArrayList from session : Inscription

    Next i want get the session in the code of the JSP

    <body>menu
    <%
    MenuAccess menuAccess = new MenuAccess();
    @SuppressWarnings(“unchecked”)
    ArrayList menuArray = new ArrayList<MenuAccess>((ArrayList<MenuAccess>) session.getAttribute(“menuArray”));
    for (int i = 0; i < menuArray.size(); i++ ) {
    menuAccess = null;
    menuAccess = (MenuAccess)menuArray.get(i);
    System.out.println(“ArrayList from session : ” + menuAccess.getName() );
    }
    %>
    </body>

    10:25:04,890 INFO [STDOUT] ArrayList from session : Inscription
    10:25:04,890 INFO [STDOUT] ArrayList from session : Inscription
    10:25:06,718 ERROR [[jsp]] “Servlet.service()” pour la servlet jsp a lancé une exception
    org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP:

    Une erreur s’est produite à la ligne: 23 dans le fichier jsp: /jsp/tiles/menu/menu.jsp
    Syntax error, annotations are only available if source level is 5.0
    20: MenuAccess menuAccess = new MenuAccess();
    21: //do this:
    22: //List<String> jlistTitles = new ArrayList<String>((ArrayList<String>) session.getAttribute(“listTitles”));
    23: @SuppressWarnings(“unchecked”)
    24: ArrayList menuArray = new ArrayList<MenuAccess>((ArrayList<MenuAccess>) session.getAttribute(“menuArray”));
    25: for (int i = 0; i < menuArray.size(); i++ ) {
    26: menuAccess = null;

    The Java -version is OK because the result of the actionBean is correct

    At the start of JBoss
    Java version: 1.5.0_12,Sun Microsystems Inc.
    10:31:19,734 INFO [ServerInfo] Java VM: Java HotSpot(TM) Client VM 1.5.0_12-b04,Sun Microsystems Inc.

    but there is one info
    10:31:28,140 INFO [AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_12\bin

    I don’t understand why JBoss don’t use the good Java -version for the JSP

    #278559 Reply

    Loyal Water
    Member

    Moving to Off Topic >> Software Development.

    #278565 Reply

    Figa
    Member

    Hi,

    I find the solution,

    Because some parameter of the org.apache.jasper.servlet.JspServlet ar initilized for Java 1.4.

    You have to change to parameter in the web.xml
    <int-param>
    <param-name>compilerSourceVM</param-name>
    <param-value>1.5</param-value>
    </init-param>
    <int-param>
    <param-name>compilerTargetVM</param-name>
    <param-value>1.5</param-value>
    <i/nt-param>

    #289703 Reply

    Edit ${jboss.home}/server/default/deploy/jboss-web.deployer/conf/web.xml
    and add the following params to the “jsp” servlet:

    <init-param>
    <param-name>compilerSourceVM</param-name>
    <param-value>1.5</param-value>
    </init-param>
    <init-param>
    <param-name>compilerTargetVM</param-name>
    <param-value>1.5</param-value>
    </init-param>

    Ref:https://jira.jboss.org/jira/browse/JBWEB-87

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: problem to get Arraylist from session in jsp

You must be logged in to post in the forum log in