First of all, John, I encourage you to learn JSTL -- really permits you to write much cleaner pages yet still do some fairly complicated logic on the JSP page.

Okay, to answer your immediate question, you can put a property value into a scripting variable using the <bean:define> tag like this:

<bean:define id="lastUpdt" name="cmateList" property="lastUpdated"/>

However, you really should avoid scripting Java in a JSP -- using JSTL your fragment could be rewritten something like as:

<c:forEach var="cmateList" items="${classmateList}">
  <br />
  <c:choose>
     <c:when test="${empty cmateList.lastUpdated or
                     cmateList.lastUpdated eq '0000-00-00'}">
         &nbsp;&nbsp;&nbsp;
     </c:when>
     <c:otherwise>*  </c:otherwise>
  </c:choose>

  <%-- Consider using the <c:url> tag here instead --%>
  <a href=BuildClassmateInfoViewAction.do?viewFirstName=<bean:write
     name="cmateList" property="firstName"/>&viewLastName=<bean:write
     name="cmateList" property="lastName"/>><bean:write name="cmateList"
     property="firstName"/> <bean:write name="cmateList"
     property="lastName"/></a><br>
</c:forEach>

-Bill Siggelkow


[EMAIL PROTECTED] wrote:




Hi guys, I am trying to pull the value from a property in a collection(LinkedList) stored in the request object and store it in a script variable. I can write the property value to the response page using a <bean:write> tag inside a <logic:iterate> tag, but I can't seem to find a way to get the value into a script variable. Below, I tried the <bean:parameter> tag with no luck (it stores null in the variable lastUpdt). Any suggestions? For collections, do I have to do something more elaborate than using the bean:parameter tag?

Here's the jsp code.  The collection is stored in the "classmateList"
attribute of the response object.  Within each bean in that collection, I
am trying to take the value of the "lastUpdated" property and store it in
the script variable "lastUpdt".
Thanks!

----------------------------------------------------------------------------------------

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<div style="text-align: justify;">
<logic:iterate id="cmateList" name="classmateList">
<%
String updatedFlag = "";
%>
<bean:parameter id="lastUpdt" name="lastUpdated" value=""/>
lastUpdated: <%=lastUpdt%><br>
<br>
<%
if (lastUpdt == "" || lastUpdt == "0000-00-00") {
    updatedFlag = "&nbsp;&nbsp;&nbsp";
}
else {
    updatedFlag = "* ";
}
%>
<%=updatedFlag%><a
href=BuildClassmateInfoViewAction.do?viewFirstName=<bean:write
name="cmateList" property="firstName"/>&viewLastName=<bean:write
name="cmateList" property="lastName"/>><bean:write name="cmateList"
property="firstName"/> <bean:write name="cmateList"
property="lastName"/></a><br>
</logic:iterate>
</div>
<br>
<br>
<div style="text-align: center; color: rgb(0, 0, 102);">
    <html:form action="/BuildHomeViewAction">
        <html:submit value="Return to Your Home Page"/>
    </html:form>
</div>



--
"NOTICE:  The information contained in this electronic mail transmission is
intended by Convergys Corporation for the use of the named individual or
entity to which it is directed and may contain information that is
privileged or otherwise confidential.  If you have received this electronic
mail transmission in error, please delete it from your system without
copying or forwarding it, and notify the sender of the error by reply email
or by telephone (collect), so that the sender's address records can be
corrected."


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to