el eval v literal

Discussion in 'Java' started by grasp06110@gmail.com, Sep 10, 2008.

  1. Guest

    Hi Everybody,

    Is there a way to get an eval of a el expression. I'm trying to
    display the contents of an ArrayList that exists in the session by
    passing in the name of the list so I would like to do something like
    send the following request:

    http://myPage?listName=myList

    and then get the list from the session and iterate through it to
    display the contents. I was hoping that ${param.listName} would
    evaluate to the literal string myList in a statement such as:

    ${${listName}}

    and then I could do something like:

    <c:forEach var="current' items="${${listName}} >

    is there a way to do this?

    Thanks,
    John
     
    , Sep 10, 2008
    #1
    1. Advertising

  2. Guest

    On Sep 10, 7:28 am, wrote:
    > Hi Everybody,
    >
    > Is there a way to get an eval of a el expression.  I'm trying to
    > display the contents of an ArrayList that exists in the session by
    > passing in the name of the list so I would like to do something like
    > send the following request:
    >
    > http://myPage?listName=myList
    >
    > and then get the list from the session and iterate through it to
    > display the contents.  I was hoping that ${param.listName} would
    > evaluate to the literal string myList in a statement such as:
    >
    > ${${listName}}
    >
    > and then I could do something like:
    >
    > <c:forEach var="current' items="${${listName}} >
    >
    > is there a way to do this?
    >
    > Thanks,
    > John


    This works but requires knowing the object is in the session up front:

    <html>

    <%@ page isELIgnored="false" %>
    <%@ taglib uri="/tld/jstl/c.tld" prefix="c" %>

    <body>
    <h2>${param.name}</h2>
    <table>
    <jsp:scriptlet>
    String listName = request.getParameter("name");
    Object list = request.getSession().getAttribute(listName);
    request.setAttribute("list", list);
    </jsp:scriptlet>
    <c:forEach var="row" items="${list}">
    <tr>
    <td>
    ${row}
    </td>
    </tr>
    </c:forEach>
    </table>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    </body>

    </html>
     
    , Sep 10, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Newton
    Replies:
    3
    Views:
    9,502
    Brock Allen
    Apr 4, 2005
  2. DataBinder.Eval and Eval.

    , Jun 16, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    570
    Karl Seguin [MVP]
    Jun 16, 2006
  3. Alex van der Spek

    eval('07') works, eval('08') fails, why?

    Alex van der Spek, Jan 8, 2009, in forum: Python
    Replies:
    6
    Views:
    1,501
    Bruno Desthuilliers
    Jan 8, 2009
  4. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    392
    Anonieko Ramos
    Sep 27, 2004
  5. Liang Wang
    Replies:
    8
    Views:
    144
    Ben Morrow
    Feb 2, 2008
Loading...

Share This Page