In JSP, I can reference the bean property using the $ {Object.property} tag
Is there a way to handle properties that may not exist? I have a JSP page that has to deal with different types. Example:
public class Person { public String getName() } public class Employee extends Person { public float getSalary() }
In JSP, I want to display a table of people with name and salary columns. If the person is not an employee, then the salary should be empty. The HTML line might look like this:
<tr> <td><c:out value="${person.name}"></td> <td><c:out value="${person.salary}"></td> </tr>
Unfortunately, if a person is not an employee, he cannot find a salary and an error will occur. How can I solve this in JSP?
Edit: Does instanceof validation exist in the JSP tag language?
java jsp javabeans jsp-tags
Steve kuo
source share