Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying the data from the list in JSP

 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am seeting the list as an attribute in the JSP which is having the values taken from the database. Such as 198526,1234895,254623
I want to display these datas in the JSP for which i have written code like this.

But the values in the List are not getting displayed. Instead i am getting something like this
com.tvs.trans.VO.AdminRequestVO@138c63 1
com.tvs.trans.VO.AdminRequestVO@138c63 2
com.tvs.trans.VO.AdminRequestVO@138c63 3
 
sudipto shekhar
Ranch Hand
Posts: 826
Chrome Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by renu richard:


But the values in the List are not getting displayed. Instead i am getting something like this
com.tvs.trans.VO.AdminRequestVO@138c63 1
com.tvs.trans.VO.AdminRequestVO@138c63 2
com.tvs.trans.VO.AdminRequestVO@138c63 3


Is this all what you get?
I mean is this the whole error message that you get?
Check that the list is set in the proper scope.

This is all what i can say.... through the code that you have posted!!
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Actually this is not the error.
I ahve two columns in my table. First column is supposed to display the content of the list.(eg:175643)
but instead it is giving something like this com.tvs.trans.VO.AdminRequestVO@138c63 (which is actually the memory address-package in my application)
And the secound column is giving the counter value like (1,2,3)
 
sudipto shekhar
Ranch Hand
Posts: 826
Chrome Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the problem is, i think in the value of the List that you are passing as the attribute.
I am sorry but i can not help.....
May be someone who knows what exactly the problem is can help!

Can you post the whole code or controller part of your app. or where you are setting the List as an attribute?
[ November 25, 2008: Message edited by: Sudipto Shekhar ]
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please see the code.



And the output is

com.tvs.trans.VO.AdminRequestVO@1c7980c 1
com.tvs.trans.VO.AdminRequestVO@1c7980c 2
com.tvs.trans.VO.AdminRequestVO@1c7980c 3
name1 1
name2 2

Now i want 198675,198656,1978562 in place of com.tvs.trans.VO.AdminRequestVO@1c7980c,com.tvs.trans.VO.AdminRequestVO@1c7980c,com.tvs.trans.VO.AdminRequestVO@1c7980c

[ November 25, 2008: Message edited by: renu richard ]
[ November 25, 2008: Message edited by: renu richard ]
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Renu,

Try this code in your jsp


See, You are setting AdminRequestVO value object to your list and your printing that object only when you write ${emp}. Instead you need empno of AdminRequestVo. Hence you have to write emp.empno.

Try this and let us know if it helps you.
Thanks
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Patricia. Thats working.

But, what i am getting is something like

198670 1
198670 2
198670 3

I have checked the size of the list in servlet by using

int n = listrequest.size();
System.out.println("size in main method:"+n);

Which shows that the list is having all the three values 198672,198669,198670.

But then, while displaying it in JSP, it is displaying only the empno of the last object in the list.
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Richard,

If you go through the line of code, you will get the answer yourself. You are creating only one object AdminRequestVO class i.e. out side the loop. Try this.




Cheers,

[ November 26, 2008: Message edited by: Patricia Samuel ]
[ November 26, 2008: Message edited by: Patricia Samuel ]
 
Srikanth Nutigattu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just want to add one more point,

when you say ${emp} it is as good as saying System.out.println(emp);

Because emp is an "object", it will call the "toString()" method. Because the "toString()" has not been overridden, you can see that the output being the output of the default toString() method.

You can do the following:

1. You can display the individual attributes of the object as Patricia Samuel suggested.

2. You override the toString() method to produce meaningful values.

Thanks.
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats right. Thanks Guys !!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic