• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get a object from a list of object using JSTL?

 
Jahir Ali Mondal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to get object value from a list of object using jstl.
<CODE>
PersonAction.javaIt is Struts action classs

Person ps1 = new Person("Jahir","Ali");
Person ps2 = new Person("Raja","Bannerjee");
Person ps3 = new Person("Suman","Chatterjee");
Person ps4 = new Person("Sayantan","Dey");
List lpersonList = new ArrayList();
lpersonList.add(ps1);
lpersonList.add(ps2);
lpersonList.add(ps3);
lpersonList.add(ps4);
request.setAttribute("plist", lpersonList);
return mapping.findForward("Success");
Person.java
public class Person {
private String firstName;
private String lastName;
public Person(String pfName,String plname){
this.firstName=pfName;
this.lastName=plname;
}
public Person(){

}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
jstl.jsp

<c:forEach var="ps" items="${requestScope.psList}">
<c ut value="${ps.firstName}"/><c ut value="${ps.lastName}"/>
</c:forEach>
<CODE>

I use jstl.1.1. I do not get any output but no exception. Before i used jstl1.0. Then a exception occurs...
According to TLD or attribute directive in tag file, attribute value does not accept any expressions
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic