This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Access dynamic attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
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: 60794
    
  65

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Access dynamic attribute
 
Similar Threads
can any body tell how to store check box value in session
Problem passing jsp:param
jsp:include & jsp:param
Problem with jsp:include
how to do Multiple checkbox binding in spring