- Using <jsp:useBean>
- Using <jsp:getProperty>
- Using <jsp:setProperty>
Using <jsp:getProperty>
One of the primary reasons for using JavaBeans is to return dynamic information. The <jsp:getProperty> action returns information from a bean as a String object. There are only two attributes in this action:
nameSpecifies the name of the bean instance from which you want to obtain the data. This must be the name of a valid bean that was instantiated by using the <jsp:useBean> action.
propertySpecifies the property within the specified bean that you want to output.
So, using the instantiated today bean, you can return the current month and date by using the following JSP code:
<jsp:getProperty name="today" property="month" /> / <jsp:getProperty name="today" property="date" />
If today is the 17th of February, this example outputs the information 2/17.