File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

accessing object from List of object using JPA & JSTL

 
Sammy Robert
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to access the object from a list of objects using JSP & JSTL without any success. I'm using JPA.

DvdRecord.java



Record.java


Now, in the JSP page


The output is printed when I do b1[0] but its 1 line with all the track names. However the 2nd output i.e. b1[0].track when used gives error saying it can't find 'track'. I want to display the track and the corresponding album name in a tabular format. How do I access the track or album variable in the for each loop of JSTL. I guess the problem is with the way JPA query puts the result into the list.

Thanks for the help.
 
Vijitha Kumara
Bartender
Posts: 3909
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

However the 2nd output i.e. b1[0].track when used gives error saying it can't find 'track'.

Can you show us the exact exception you see in the JSP?
 
Sammy Robert
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is the error

This is from the glassfish server output window. (I am using NetBeans IDE to develop the project)


The error says that there is no method in the list with the name 'track' I even tried using the get property as .getTrack() without any luck. However I'm populating the bRListM (which is list of Record objects) as shown previously in the DvdRecord.java class. I'm not sure but i think the way JPA query is inserting into the list is not proper. Any feedback would be appreciated.
Thank You.
 
Vijitha Kumara
Bartender
Posts: 3909
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...The class 'java.lang.String' does not have the property 'track'.

According to this it looks like that the expression "b1[0]" returns a String value not an object where you expect it to be...

And what is the relationship between DvdRecord and the Record classes? Are you populating and using the correct domain class here?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic