If you use <c:set var="totalPosts" value="${requestScope.TotalPosts}" /> then <c:out value="${totalPosts}" /> will work on the same JSP.
Otherwise <c:set var="totalPosts" value="${requestScope.TotalPosts}" scope="request"/> is required for the variable to be available at <c:out value="${requestScope.totalPosts}" /> *Note the case of totalPosts and TotalPosts above and the scope variable used* Without calling a c:set method (and the variable TotalPosts exists on the request) then <c:out value="${requestScope.TotalPosts}" /> should work fine. It can get confusing when using similiarly named variables or same name different case variables. You should try and avoid it for sake of your sanity and readability :) hth Chris McCormack -----Original Message----- From: Karr, David [mailto:[EMAIL PROTECTED] Sent: 21 June 2004 16:09 To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: Please Help Me To Convert My JSP Scripting Elements To <c:set ..> <c:out ..> Tags > -----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] *********************************************** This e-mail and its attachments are confidential and are intended for the above named recipient only. If this has come to you in error, please notify the sender immediately and delete this e-mail from your system. You must take no action based on this, nor must you copy or disclose it or any part of its contents to any person or organisation. Statements and opinions contained in this email may not necessarily represent those of Littlewoods. Please note that e-mail communications may be monitored. The registered office of Littlewoods Limited and its subsidiaries is 100 Old Hall Street, Liverpool, L70 1AB. Registered number of Littlewoods Limited is 262152. ************************************************ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]