File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes displaying data from a single request object in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "displaying data from a single request object in struts2" Watch "displaying data from a single request object in struts2" New topic

displaying data from a single request object in struts2

aihadus tisidns

Joined: Nov 14, 2008
Posts: 9
Following are the bean class,jsp class and action class used in struts2.
Problem is:-I am displaying data through a request object in jsp class
<s roperty id="detail" value="#request['custinfo']" />
Through this tag,but it is fetching all the data in request object and displaying.

I have many fields such as
customerBasicInfoVo.setNameLine1("PHILLIP W ROBINSON");
and so on��I want all PersBusinessInd to be displayed in different <td> in jsp and NameLine1 to be in different <td>.
I am not able to do that because everything is in single request object.

Is there any way to iterate the values I am entering in the string buffer�I used list also but again the problem is same all data is being displayed in single <td> only

Bean Class

public class CustomerDetailedInfoVo {

private CustomerBasicInfoVo customerBasicInfoVo;
private ClientSearchByOlbIdVo clientSearchByOlbIdVo;

public CustomerBasicInfoVo getCustomerBasicInfoVo() {
return customerBasicInfoVo;

public void setCustomerBasicInfoVo(CustomerBasicInfoVo customerBasicInfoVo) {
this.customerBasicInfoVo = customerBasicInfoVo;

public ClientSearchByOlbIdVo getClientSearchByOlbIdVo() {
return clientSearchByOlbIdVo;

public void setClientSearchByOlbIdVo(ClientSearchByOlbIdVo clientSearchByOlbIdVo) {
this.clientSearchByOlbIdVo = clientSearchByOlbIdVo;

public String toString(){
StringBuffer str=new StringBuffer();



return str.toString();


JSP Page


<td>PersBusinessInd: </td>
<s roperty id="detail" value="#request['custinfo']" />



Action Class

public String execute() throws Exception {
CustomerDetailedInfoVo customerDetailedInfoVo=new CustomerDetailedInfoVo();
CustomerBasicInfoVo customerBasicInfoVo=new CustomerBasicInfoVo();

getServletRequest().setAttribute("custinfo", customerDetailedInfoVo);
return SUCCESS;
David Newton

Joined: Sep 29, 2008
Posts: 12617

Please use UBB code to format your code (and disable smilies).

Your property tag is <s:property value="#request['custinfo']"/>, so it'll display the entire object. Use OGNL to get a specific property of the 'custinfo' object: #request['custinfo'].firstName or whatever.

That said, this is non-canonical Struts 2. Normally objects to be displayed in the JSP would be an action property with a public getter, so in the JSP you could use either of the following:

[ November 17, 2008: Message edited by: David Newton ]
I agree. Here's the link:
subject: displaying data from a single request object in struts2
It's not a secret anymore!