I am trying to send a value as a request variable to action class.But I am getting an exception. My code is <logic:iterate name="searchResultsForm" id="results" property="searchResults" type="com.ng.wft.wl.form.SearchUserForm" scope="session"> <tr> <td><html:link action="/searchUser.do?user=<bean:write name="results" property="userId"/>&methodToCall='showDetails'"><bean:write name="results" property="userId" /></html:link></td> <td><bean:write name="results" property="firstName" /></td> <td><bean:write name="results" property="lastName" /></td> </logic:iterate>
You can't use a <bean:write> tag inside an <html:link> tag. Struts doesn't support it.
The easiest way to fix this is to abandon use of <html:link> and just use the plain old html tags <a></a>. Then you will have no problem substituting parameters with <bean:write> tags.
The only advantage <html:link> has over the plain html tag is that it automatically does URL rewriting (Adding of the jsessionid to the URL so that sessions may be tracked even if the user has turned cookies off). If you're not using this function anyway, as most modern websites don't, you may as well use the html tag.
If you still want to use <html:link>, use the struts-el version of the html tags and use EL expressions instead of <bean:write> tags.