Access variables in JSTL tag

Discussion in 'Java' started by Jon Rasmussen, Jul 8, 2004.

  1. JSP/JSTL:
    I have a JSP page with some sciptlets

    <%
    String title="My page";
    %>

    I want to use
    <c:eek:ut value='${title}' />
    JSTL tag to output the result.

    How can I access the Java variable in the tag?

    Cheers,

    Jon Rasmussen
    Jon Rasmussen, Jul 8, 2004
    #1
    1. Advertising

  2. Jon Rasmussen

    Ryan Stewart Guest

    "Jon Rasmussen" <> wrote in message
    news:...
    > JSP/JSTL:
    > I have a JSP page with some sciptlets
    >
    > <%
    > String title="My page";
    > %>
    >
    > I want to use
    > <c:eek:ut value='${title}' />
    > JSTL tag to output the result.
    >
    > How can I access the Java variable in the tag?
    >

    X.setAttribute("title", title);
    where "X" is one of pageContext, request, session, or application. This kind
    of thing is typically done in a Struts Action though.
    Ryan Stewart, Jul 8, 2004
    #2
    1. Advertising

  3. "Jon Rasmussen" <> schrieb im Newsbeitrag
    news:...
    > JSP/JSTL:
    > I have a JSP page with some sciptlets
    >
    > <%
    > String title="My page";
    > %>
    >
    > I want to use
    > <c:eek:ut value='${title}' />
    > JSTL tag to output the result.
    >
    > How can I access the Java variable in the tag?


    By using

    <c:set var="title" value="My page"/>

    instead of a scriptlet.


    Greets,

    Roman
    Roman Seibold, Jul 9, 2004
    #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. shahbaz
    Replies:
    0
    Views:
    880
    shahbaz
    Oct 27, 2003
  2. Crowther
    Replies:
    0
    Views:
    3,852
    Crowther
    Nov 19, 2003
  3. Robert Mark Bram

    Custom JSTL that accepts JSTL expression

    Robert Mark Bram, Dec 15, 2004, in forum: Java
    Replies:
    0
    Views:
    941
    Robert Mark Bram
    Dec 15, 2004
  4. shruds
    Replies:
    1
    Views:
    710
    John C. Bollinger
    Jan 27, 2006
  5. DaFoot
    Replies:
    1
    Views:
    1,657
    DaFoot
    Oct 23, 2008
Loading...

Share This Page