> -----Original Message----- > From: Caroline Jen [mailto:[EMAIL PROTECTED] > > I am converting all the scripting elements in my JSP > to <c:.... > tags. I have decided to go one step at > the time -- I only want to print out one basic number > as a start. > > My action class passes an object "TotalPosts" in > the following way to my JSP: > > request.setAttribute( "TotalPosts", new Integer( > totalPosts ) ); > return ( mapping.findForward( "success" ) );
First of all, you probably should use property names that begin with a lowercase letter. It just might work beginning with a capital, but you also may run into unexpected trouble. > Now, I have the struts-html-el.tld downloaded and put > the following in my application's web.xml file: > > <taglib> > <taglib-uri>/tags/struts-html-el</taglib-uri> > > <taglib-location>/WEB-INF/lib/struts-html-el.tld</taglib-location> > </taglib> > > And in my JSP, I imported the following: > > <%@ taglib uri="/tags/struts-html-el" prefix="html" %> > <%@ taglib uri="/tags/struts-bean" prefix="bean" %> > <%@ taglib uri="/tags/struts-logic" prefix="logic" %> > <%@ taglib uri="/tags/tiles" prefix="tiles" %> Assuming you're using a standard Servlet 2.3 container, you might consider using the "normalized" URI for each taglib (the value of the "uri" property in the tld). This allows you to avoid having to store the TLD separately from the taglib jar, and avoids the need to add the taglib element to your web.xml. It still requires the taglib directive in the JSP (using the normalized URI). Also, as another posted pointed out, you're missing the "core" taglib directive. Without that, your reference to the "c:out" tag would have been untranslated (the html output would still contain "<c:out .../>". > I replaced: > > int totalPosts = ( ( Integer )request.getAttribute( > "TotalPosts" ) ).intValue(); > with > <c:set var="totalPosts" > value="${requestScope.TotalPosts}" /> Note that there's no need to do this. If the variable is already available in request scope, there's no need to set it into another variable in page scope. > And I replaced: > > <%=totalPosts%> > with > <c:out value="${requestScope.totalPosts}" /> > > I cannot print out anything. I got a 'BLANK'. > > There must be something I missed. What did go wrong? If your property name was "totalPosts", instead of "TotalPosts", and you had the correct taglib directive in your JSP, then this should have worked. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]