In the user.jsp page we iterate the userList using the <logic:iterate> tag. The id attribute of the <logic:iterate> tag holds an instance of the data present in the userList. userList contains a list of UserData. So the id attribute holds an instance of the UserData. Using the <bean:write> tag we display the data present in the UserData.
The exportUser.jsp page contains the following contents.
The user.jsp page contains the following user details.
On clicking the Excel link in the user.jsp page. The userDetails.jsp page will be displayed in the Excel fromat.
<bean:write name="data" property="userName" />
The above mentioned tag calls the getUserName() method of the UserData class and displays the user name. A link is provided to export the exportUser.jsp page to excel. The exportUser.jsp page contains similar data like the user.jsp page except the contentType attribute of the page directive, which is set to application/vnd.ms-excel.
You can download the source code of this example by clicking on the Download link below.