Java Beans
Using JSP EL to display the Stock object calls its toString() method.
${stock}
<%-- Stock [symbol=ZTS, name=Zoetis Inc., price=79.73] --%>
Use the . (dot) operator to access bean properties by name.
${stock.price}
${stock.symbol}
${stock.name}
These properties correspond to the Java class's getter methods.

Practice Exercise¶
${stock.price}is NOT referring to theprivate double pricefield inStock. * JSP EL's.operator can only look for getter methods. * The getter must be namedgetPrice()for${stock.price}to work correctly. Similarly,${stock.symbol}requires the JavaBean gettergetSymbol().
Drill¶
ExpressionLanguage/src/main/webapp/WEB-INF/select.jsp
- Change the page to output the stock's properties. Output
symbolandvaluewith bullets.name * symbol * price(Solution: /WEB-INF/solutions/selectProperties.jsp, com.example.el.solutions.servlets.StockServletProperties)