my dog learned polymorphism
The moose likes JSP and the fly likes Access dynamic attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Access dynamic attribute" Watch "Access dynamic attribute" New topic
Author

Access dynamic attribute

kevin hack
Greenhorn

Joined: Jun 20, 2011
Posts: 6
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

Joined: Jan 31, 2008
Posts: 7
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

Joined: Jun 20, 2011
Posts: 6
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

Joined: Jan 10, 2002
Posts: 56157
    
  13

I'd use a tag file rather than an include. That way you can pass scooped variables of any type.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: jrebel
 
subject: Access dynamic attribute
 
Similar Threads
how to do Multiple checkbox binding in spring
can any body tell how to store check box value in session
Problem passing jsp:param
jsp:include & jsp:param
Problem with jsp:include