getProperty action of JSP:
<jsp:getProperty /> action is used to write the value a bean property to the output stream. It is used when a property value is to be sent as response.
It has following syntax:
Let following be an external object in a JSP page.
To write the value of mailId property of the user bean to the output stream, following action is required.
Following code will be generated in the _jspService() method of the auto generated servlet:
//MailId property value is written to the output stream out.print(user.getMailId());
As you can see from the above example, it is a very simple action to use. It also doesn’t offer much convenience i.e. most of the time the statement which is generated for this action is more compact than the action itself. Instead of the action, that statement can be directly used in the scriptlet tag by a JSP programmer.
In the next post, use of <jsp:useBean />, <jsp:setProperty /> and <jsp:getProperty /> actions is demonstrated with the help of a practical example.