I tried this out:-
I made a Person class with:-
private
String name;
private Dog dog;
I made appropriate setter and getters for all properties.
Here Dog is another class that we dont need to worry bout right now.
The
servlet creates a Dog object and a Person object and sets the Dog object as the persons dog. Sets the name as something. assigns the Person as a request attribute "person" n forwards the request to a
JSP.
now in the JSP :-
${person.name} prints the person objects correct name.
${request.person.name} prints the person objects correct name.
Now this is where it gets interesting:-
${person.age} throws exception, because Person has no 'age' property
${person["age"]} throws exception, because Person has no 'age' property
Now it gets more interesting:-
${request.person.age} it prints nothing.
${request.person["age"]} it prints nothing.
So how is that possible, the behavior is not consistent, its throwing an exception when I dont use the request scope implicit object???
Any suggestions??