JSP struts tag error

Discussion in 'Java' started by P.Hill, Jun 21, 2005.

  1. P.Hill

    P.Hill Guest

    I am having trouble getting certain tags to work.

    My struts action places various things in the sessions
    (bibliosTotal, biblio1, biblios) The following bare EL work fine.
    The scriplet works fine and prints an expected value out.
    But the use of the logic:notPresent tag results in the value
    not being identified as present, so it also prints a message
    despite being in direct conflict with the previous bit of code.

    Any suggestions?


    Am I not supposed to be trying to mix and match struts tags with
    'modern' jstl?



    Total Biblios: ${bibliosTotal} </br>
    1st bibliography: ${biblio1} </br>
    <p>
    <%
    out.println( ((List)(session.getAttribute( "biblios" ))).size());
    %>
    </p>
    <p>
    <logic:notPresent name="${biblios}" scope="session">
    There are NO biblios (Using logic:notPresent).</br>
    </logic:notPresent>

    The top of the file contains:
    <%@ taglib uri="/tags/struts-logic" prefix="logic" %>

    My web.xml contains:
    <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
    </taglib>


    jstl.jar, standards.jar and struts.jar (plus many others) are in my
    WEB-INF/lib directory.
     
    P.Hill, Jun 21, 2005
    #1
    1. Advertising

  2. P.Hill

    Wendy Smoak Guest

    "P.Hill" <> wrote

    > <logic:notPresent name="${biblios}" scope="session">
    > There are NO biblios (Using logic:notPresent).</br>
    > </logic:notPresent>


    You've asked it whether there is an object in session scope under the key
    [whatever ${biblios} evaluates to]. So, what _does_ ${biblios} evaluate to?

    I suspect that you really want this:
    <logic:notPresent name="biblios" scope="session">

    But if you've got JSTL, I would suggest using <c:if> instead of
    <logic:notPresent>.

    Maybe...
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <c:if test="${empty biblios}">
    ...
    </c:if>

    BTW, you don't have to put the tlds in WEB-INF and map them in web.xml. The
    tlds are inside the various .jar files, if you use the correct URI, they
    will automatically be located.

    --
    Wendy Smoak
     
    Wendy Smoak, Jun 21, 2005
    #2
    1. Advertising

  3. P.Hill

    P.Hill Guest

    Wendy Smoak wrote:
    > I suspect that you really want this:
    > <logic:notPresent name="biblios" scope="session">


    Yes, I did want the value of the object 'biblios' not the value of the
    object pointed to by the value of biblios.
    Thanks,

    > Maybe...
    > <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    > <c:if test="${empty biblios}">
    > ...
    > </c:if>


    That is really the right way, I was just trying all the libs, because
    something wasn't working, for example:

    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    ....
    <c:if test="${empty biblios}">
    There are NO biblios (Using c:if).</br>
    </c:if>

    Results in:

    org.apache.jasper.JasperException: /pages/Biblio.jsp(23,0) According to
    TLD or attribute directive in tag file, attribute test does not accept
    any expressions
    (The c:if is line 23)

    > BTW, you don't have to put the tlds in WEB-INF and map them in web.xml. The
    > tlds are inside the various .jar files, if you use the correct URI, they
    > will automatically be located.


    Maybe that's part of my c: problem. I have jstl.jar and standard.jar
    from the jakarta-taglibs-standard-1.1.2 distribution and all I see are
    some classes and a MF file in both.

    But the README with the distribtion does say:

    "To use this distribution with your own web applications, simply copy
    the JAR files in the 'lib' directory (jstl.jar and standard.jar) to your
    application's WEB-INF/lib directory"

    I'm running tomcat 5.0.19 and trying to use
    jakarta-taglibs-standard-1.1.2 with dates on the jars from October 2004
    (which is a little confusing because 1.1 implements the JSP 2.0 spec if
    I understand at least this correctly).

    When I comment out all of the standard http://java.sun.com/jsp/jstl/
    references in my web.xml (despite not seeing any TLDs in the jars), I
    get exactly the same error; "attribute test does not accept any expressions"

    Any help would be deeply appreciated.

    -Paul
     
    P.Hill, Jun 21, 2005
    #3
    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. kishan bisht

    struts tag inside a tag

    kishan bisht, Jul 8, 2003, in forum: Java
    Replies:
    1
    Views:
    1,508
    Wendy S
    Jul 9, 2003
  2. Matthias Nietz
    Replies:
    1
    Views:
    3,479
    VisionSet
    Nov 12, 2003
  3. shruds
    Replies:
    1
    Views:
    896
    John C. Bollinger
    Jan 27, 2006
  4. jb
    Replies:
    1
    Views:
    4,456
  5. Oleg Konovalov
    Replies:
    1
    Views:
    4,016
    Richard Senior
    Aug 14, 2007
Loading...

Share This Page