struts and tablib question

J

jackie

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 ?
 
S

Sudsy

jackie said:
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.
 
M

Murray

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 ;-)
 
J

jackie

thanks all, all of you are very great !

Murray said:
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 ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top