copy data from JSTL tag to Java Variable.

Discussion in 'Java' started by shaji, Jan 17, 2006.

  1. shaji

    shaji Guest

    I have a JSP page with some sciptlets.

    <% String myname = "";
    pageContext.setAttribute("myname",myname);
    %>
    <c:set var="myname" value="sherlok" />

    Now I have copied the value "sherlok" to variable myname.
    I can see the setting by
    set value is: <c:eek:ut value='${myname}'/>
    This works fine as it prints out jstl variable myname.

    But below statement doesnt work.
    set value is: <%=myname%>

    How can I get the value into a java variable from a jstl variable?


    -Regards,
    spa
     
    shaji, Jan 17, 2006
    #1
    1. Advertising

  2. shaji

    shaji Guest

    Re: copy data from JSTL tag to Java Variable.

    FYI:

    Solution is:

    Depending upon the context of the binding of jstl variable, you can
    get the value from the appropriate context.
    Mainly they are application, request, session and page

    In my case it was page:
    <% String myname = pageContext.getAttribute("myname"); %>

    -thanks
     
    shaji, Jan 17, 2006
    #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. shahbaz
    Replies:
    0
    Views:
    931
    shahbaz
    Oct 27, 2003
  2. Robert Mark Bram

    Custom JSTL that accepts JSTL expression

    Robert Mark Bram, Dec 15, 2004, in forum: Java
    Replies:
    0
    Views:
    1,000
    Robert Mark Bram
    Dec 15, 2004
  3. shruds
    Replies:
    1
    Views:
    893
    John C. Bollinger
    Jan 27, 2006
  4. Replies:
    0
    Views:
    3,353
  5. DaFoot
    Replies:
    1
    Views:
    1,731
    DaFoot
    Oct 23, 2008
Loading...

Share This Page