• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Access dynamic attribute

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Quick! Before anybody notices! Cover it up with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic