Mega Code Archive

 
Categories / Java / JSP
 

Get Set Properties JSTL

//File: index.jsp <html>     <head>         <title>Using a JavaBean</title>     </head>     <body>     <h2>Using a JavaBean</h2>     <jsp:useBean id="myCar" class="beans.CarBean" />     I have a <jsp:getProperty name="myCar" property="make" /> <br />     <jsp:setProperty name="myCar" property="make" value="Ferrari" />       Now I have a <jsp:getProperty name="myCar" property="make" />     </body> </html> ////////////////////////////////////////////////////////////// //Java Bean package beans; import java.io.Serializable; public class CarBean implements Serializable  {   private String make = "Company";   private double cost = 100.00;   private double taxRate = 17.5;   public CarBean() {}   public String getMake()   {     return make;   }   public void setMake(String make)   {     this.make = make;   }   public double getPrice()   {     double price = (cost + (cost * (taxRate/100)));     return price;   } }                     GetSetPropertiesJSTL.zip( 89 k)