Search code examples
javajsphyperlinkstrutsjavabeans

Pass object from JSP to a action class in Struts 1.3


I want to pass an object from JSP to an action class. How to do it? I have no idea regarding it. Some of my sample codes are here:

<tr class="alt">
    <td><html:link href=""><bean:write name="EmpInfo" property="empId" /></html:link></td>
    <td><bean:write name="EmpInfo" property="empName" /></td>
    <td><bean:write name="EmpInfo" property="empAddress" /></td>
    <td><bean:write name="EmpInfo" property="empPhNumber" /></td>
    <td><bean:write name="EmpInfo" property="empEmailId" /></td>
    <td><bean:write name="EmpInfo" property="empLocName" /></td>
    <td><bean:write name="EmpInfo" property="empCountryName" /></td>
    <td><bean:write name="EmpInfo" property="empDob" /></td>
    <td><html:link href=""><bean:message key="view.single.emp.update"/></html:link></td>
</tr>

in the above code in the <html:link href=""> tag i wanna pass the empId or the object EmpInfo to an action class. Here's EmpInfo is value object and it has all the getter and setters in it.


Solution

  • Use the html:param tag, it could be used in the body of html:link tag

    <html:link href=""><html:param name="empId"><bean:write name="EmpInfo" property="empId" /></html:param></html:link>