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

Access dynamic attribute

 
kevin hack
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I need to develope modular dinamic jsp. This is my example:

class People {
String name;
String age;
...
getter and setter methods...
}

class myClass {
People man;
People girl;
....
getter and setter methods...
}

In my controller, action or other... request.setAttribute("myObj", instanceOfMyClass)

In my JSP1, I can get instanceOfMyClass request.getAttribute("myObj");

In my JSP1, I want call 2 same include:

<jsp:include page="printPeople.jsp">
<jsp:param value="${instanceOfMyClass.man}" name="people"/> How can I pass People object to printPeople.jsp??? Now man istance
</jsp:include>

<jsp:include page="printPeople.jsp">
<jsp:param value="${instanceOfMyClass.girl}" name="people"/> How can I pass People object to printPeople.jsp??? Now girl istance
</jsp:include>

I want create JSP2 that print People informations:

<c:out value="${people.name}" />
<c:out value="${people.age}" />

How can I solve my problem?

Thanks in advance?
 
Shrivastava Amit
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String data type is only allowed to be passed to included JSP.

You need to pass name variable value to included JSP instead of actual object like


In printPeople.jsp

 
kevin hack
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shrivastava Amit wrote:String data type is only allowed to be passed to included JSP.

You need to pass name variable value to included JSP instead of actual object like


In printPeople.jsp



Thanks for reply, but I want pass instance of object and not all properties (name, age, etc...)

Is it not possible?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd use a tag file rather than an include. That way you can pass scooped variables of any type.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic