Checking attribute exists in JSP
- by Javi
Hello,
I have some classes which extends a superclass, and in the JSP I want to show some attributes of these classes. I only want to make one JSP, but I don't know in advance if the object has an attribute or not. So I need a JSTL expression or a tag which checks that the object I pass has this attribute (similar to in operator in javascript, but in the server).
<c:if test="${an expression which checks if myAttribute exists in myObject}">
<!-- Display this only when myObject has the atttribute "myAttribute" -->
<!-- Now I can access safely to "myAttribute" -->
${myObject.myAttribute}
</C:if>
How can I get this?
Thanks.