struts and tablib question

Discussion in 'Java' started by jackie, Jun 23, 2004.

  1. jackie

    jackie Guest

    How can I make use of java variable in taglib in a JSP ?

    e.g

    <%
    String number="123";
    %>

    <c:eek:ut value="${number}"/>


    How can I do it ?
     
    jackie, Jun 23, 2004
    #1
    1. Advertising

  2. jackie

    J Guest

    > How can I make use of java variable in taglib in a JSP ?

    <c:eek:ut value="<%= number %>"/>
     
    J, Jun 23, 2004
    #2
    1. Advertising

  3. jackie

    Sudsy Guest

    jackie wrote:
    > How can I make use of java variable in taglib in a JSP ?


    Others have given you the essentials. Use something like this:

    <c:eek:ut value="<%= number %>"/>

    Only thing is that if you check c.tld then you'll note that
    rtexprvalue (run time expression value) is set to false. You
    therefore require the c-rt.tld file.
    Have something like this at the top of your page:

    <%@ taglib uri="c-rt" prefix="c" %>

    That would require an entry like this in WEB-INF/web.xml:

    <taglib>
    <taglib-uri>c-rt</taglib-uri>
    <taglib-location>/WEB-INF/tlds/c-rt.tld</taglib-location>
    </taglib>

    I stick TLDs in a subdirectory underneath WEB-INF so you'll
    have to change the above to correspond to your particular
    structure.
     
    Sudsy, Jun 23, 2004
    #3
  4. jackie

    Murray Guest


    > How can I make use of java variable in taglib in a JSP ?
    >
    > e.g
    >
    > <%
    > String number="123";
    > %>
    >
    > <c:eek:ut value="${number}"/>
    >
    >
    > How can I do it ?


    Do what others have said, or just put the value onto the page context

    <%
    String number="123";
    pageContext.setAttribute("number", number);
    %>

    <c:eek:ut value="${number}"/>

    Or get rid of the need for scriplets by changing to an MVC architecture.But
    that's another matter ;-)
     
    Murray, Jun 24, 2004
    #4
  5. jackie

    jackie Guest

    thanks all, all of you are very great !

    Murray <> wrote in message
    news:40da91e9$0$18196$...
    >
    > > How can I make use of java variable in taglib in a JSP ?
    > >
    > > e.g
    > >
    > > <%
    > > String number="123";
    > > %>
    > >
    > > <c:eek:ut value="${number}"/>
    > >
    > >
    > > How can I do it ?

    >
    > Do what others have said, or just put the value onto the page context
    >
    > <%
    > String number="123";
    > pageContext.setAttribute("number", number);
    > %>
    >
    > <c:eek:ut value="${number}"/>
    >
    > Or get rid of the need for scriplets by changing to an MVC

    architecture.But
    > that's another matter ;-)
    >
    >
     
    jackie, Jun 24, 2004
    #5
    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. Katie Wright
    Replies:
    8
    Views:
    4,252
    Andrea Desole
    Jan 7, 2005
  2. Jason Us
    Replies:
    0
    Views:
    991
    Jason Us
    Oct 4, 2003
  3. jc1771
    Replies:
    0
    Views:
    407
    jc1771
    Dec 28, 2003
  4. sin
    Replies:
    3
    Views:
    725
    Sudsy
    Feb 22, 2004
  5. Merlijn
    Replies:
    0
    Views:
    3,454
    Merlijn
    Mar 24, 2006
Loading...

Share This Page