Results 1 to 7 of 7

Thread: JSTL question: expression in expression?

  1. #1

    Default JSTL question: expression in expression?

    Hi,

    how can I make an expression in an expression?

    I've got something like this:

    Code:
    ...
    <c&#58;set var="CURGEGENSTANDLEHRER" value="LEHRERPRE" />
    <%@ include file="/selectLehrer.jsp" %>
    ...
    selectLehrer.jsp:
    Code:
    <c&#58;forEach var="lehrer" items="$&#123;CURGEGENSTANDLEHRER&#125;" varStatus="status">
    <c&#58;out value="$&#123;lehrer.vorname&#125;" /><c&#58;out value="$&#123;lehrer.
    </c&#58;forEach>
    which gives me an exception that no 'vorname' property is found in object of type String. Actually, the forEach loop is only run through once, because the items are filled only with the String 'LEHRERPRE'. Actually, I want it to be filled with an Collection LEHRERPRE which is in request scope. Therefore, I'd need something like

    items="${${CURGEGENSTAND}}" in order to make it being expressed as
    items="${LEHRERPRE}"

    I appreciate any suggestions and ideas.

    Thanks in advance and kind regards,
    Simon

  2. #2
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    Unfortunately this is not possible using JSTL .

    You could use JSP fragments/tagfiles and pass those parameters, but you're still stuck with multiple files AFAIK.

    regards,
    Alef Arendsen
    Alef Arendsen
    SpringSource
    http://www.springsource.com

  3. #3

    Default

    Ok, thank you. Do you have any ideas for a workaround?

    Thanks,
    Simon

  4. #4
    Join Date
    Feb 2005
    Posts
    217

    Default

    You could extend javax.servlet.jsp.jstl.core.LoopTagSupport and make your own tag.

  5. #5
    Join Date
    Aug 2004
    Location
    Boston MA
    Posts
    27

    Default

    I think I am a bit confused. A variable named 'LEHRERPRE' is in request scope and you wish to iterate through this collection? Or do you wish to have the variables 'CURGEGENSTANDLEHRER' and 'LEHRERPRE" share the same reference?


    Keller

  6. #6

    Default

    I wanted to iterate through my LEHRERPRE array, yes.
    However, I left the additional file selectLehrer.jsp now and simply c&p'ed the part from this file.

    Thanks.

    Kind regards,
    Simon

  7. #7
    Join Date
    Aug 2004
    Location
    Boston MA
    Posts
    27

    Default

    And this doesn't work either (using ${} in the value attribute):

    <c:set var="CURGEGENSTANDLEHRER" value="${LEHRERPRE}" />

    Assuming LEHRERPRE is a request attribute.

    If you are doing this:

    <c:set var="CURGEGENSTANDLEHRER" value="LEHRERPRE" />

    What you're experiencing is correct, you are setting CURGEGENSTANDLEHRER to be a string with a value of "LEHRERPRE" since you are not using ${} to signify a variable named LEHRERPRE.

    You can set references in JSTL using the example from above. I'm still not exacly clear on what you are trying to accomplish so I hope this helps alittle.


    Keller

Similar Threads

  1. Forgot password (e.g. secret question) using Acegi
    By lowerymb77 in forum Security
    Replies: 1
    Last Post: Oct 16th, 2005, 10:46 PM
  2. Replies: 0
    Last Post: Jul 19th, 2005, 02:31 AM
  3. Spring + Hibernate ORA-00936: missing expression
    By Hugh_la_Main in forum Data
    Replies: 1
    Last Post: Jun 28th, 2005, 08:48 AM
  4. JSTL 1.0 why?
    By robododge in forum Web
    Replies: 4
    Last Post: Nov 11th, 2004, 12:52 PM
  5. Replies: 2
    Last Post: Sep 13th, 2004, 04:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •