Hello Folks,
given the scriptlet code in a
jsp ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<%Person p = new Person();
p.name = "John";
Dog d = new Dog();
d.setBreed("Poodle");
request.setAttribute("personObj",p);
request.setAttribute("dogObj",d);%>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
and assuming that Person class is a bean with two properties name(
String) and dog(Dog)
why does this work:
<c:set target="${personObj}" property="dog" value="${dogObj}" />
but this doenst:
<c:set target="${personObj}" property="dog">
${dogObj}
</c:set>
With the second version, I get the following exception:
javax.servlet.ServletException: Attempt to convert String "com.example.model.Dog@106989e" to type "com.example.model.Dog", but there is no PropertyEditor for that type
As far as I understood, its because the no-body version will accept any
java objects whereas the body version will accept only strings unless something called a "Property Editor" is not constructed for it.
Is my understanding correct or am i missing something?