Take the 2-minute tour ×

I am new to Struts2. I have a JSP page which shows a list of Rooms (where Room is a user-defined class). I need to send this entire list to the action class as a hidden field. The JSP code is as follows:

<form method="GET" action="reporting.action" >  
  <s:hidden name="roomsReport" value="%{allRooms}"/>
  <s:textfield name="roomsR" value="%{allRooms}"/>                       
  <s:submit name="action" style="width:220px;" value="Generate Report for Rooms" /> 

The textfield (used for testing) shows the address for the list (implying that its not null in the jsp page) I am still unable to access it in my ReportingAction class using the following code:


Both above print statements give 0 and [] respectively. I have the getters and setters for roomsReport as follows:

private List<Room> roomsReport;
public List<Room> getRoomsReport() {
  return roomsReport;

public void setRoomsReport(List<Room> roomsReport) {
  this.roomsReport = roomsReport;

Can anyone help ?

share|improve this question
try to print the value using getters as struts action sets values directly in to setters –  Ashes Mar 25 at 6:22
ya tried using getRoomsReport().size(); Still giving the same empty set. It seems that the getters are not even returning null (else it would give a null pointer exception). They are returning an empty set. –  Crusaderpyro Mar 25 at 6:41
@A5l-lE5: Values are not being set when someone does something wrong. –  Aleksandr M Mar 25 at 8:21
@Crusaderpyro: You cannot just pass whole object in hidden field. –  Aleksandr M Mar 25 at 8:23
The answer is: use session. –  Andrea Ligios Mar 25 at 9:25

1 Answer 1

Finally I could pass the list to the jsp using session

The list is set in a session variable in jsp as follows:

 <s:set name="roomsReport" value="%{allRooms}" scope="session" /> 

In the action class I can access it using the following code:

List<Room> roomsReport = (List<Room>)ActionContext.getContext().getSession().get("roomsReport");
share|improve this answer
If you putting things into session do it inside an action and not in view. –  Aleksandr M Mar 26 at 9:35

Your Answer


