Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > struts and tablib question

Reply
Thread Tools

struts and tablib question

 
 
jackie
Guest
Posts: n/a
 
      06-23-2004
How can I make use of java variable in taglib in a JSP ?

e.g

<%
String number="123";
%>

<cut value="${number}"/>


How can I do it ?


 
Reply With Quote
 
 
 
 
J
Guest
Posts: n/a
 
      06-23-2004
> How can I make use of java variable in taglib in a JSP ?

<cut value="<%= number %>"/>



 
Reply With Quote
 
 
 
 
Sudsy
Guest
Posts: n/a
 
      06-23-2004
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:

<cut 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.

 
Reply With Quote
 
Murray
Guest
Posts: n/a
 
      06-24-2004

> How can I make use of java variable in taglib in a JSP ?
>
> e.g
>
> <%
> String number="123";
> %>
>
> <cut 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);
%>

<cut value="${number}"/>

Or get rid of the need for scriplets by changing to an MVC architecture.But
that's another matter


 
Reply With Quote
 
jackie
Guest
Posts: n/a
 
      06-24-2004
thanks all, all of you are very great !

Murray <(E-Mail Removed)> wrote in message
news:40da91e9$0$18196$(E-Mail Removed) u...
>
> > How can I make use of java variable in taglib in a JSP ?
> >
> > e.g
> >
> > <%
> > String number="123";
> > %>
> >
> > <cut 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);
> %>
>
> <cut value="${number}"/>
>
> Or get rid of the need for scriplets by changing to an MVC

architecture.But
> that's another matter
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse and Ant with Struts: how to combine to generate javadoc api, how to map struts source to binary code for debugging Merlijn Java 0 03-24-2006 01:47 PM
Is it safe to point to Internet for locating struts DTD files in struts TLDs and XML files? Katie Wright Java 8 01-07-2005 03:37 PM
[Struts]output javascript in struts perform() sin Java 3 02-22-2004 08:27 AM
Integrate a Struts app with a non-struts app jc1771 Java 0 12-28-2003 06:36 PM
Struts Installation - missing struts.tld??? Jason Us Java 0 10-03-2003 11:36 PM



Advertisments