Use Of Bean In JSP

Discussion in 'JSP' started by angad_aks, Feb 15, 2011.

  1. angad_aks

    angad_aks Banned

    Joined:
    Feb 15, 2011
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    <html>
    <head>
    	<title>SimpleBean Test Page</title>
    </head>
    <body>
    
    <%-- Creating JavaBeans --%>
    <jsp:useBean id="simple" class="com.stardeveloper.bean.test.SimpleBean">
    	<jsp:setProperty name="simple" property="name" value="Faisal Khan" />
    	<jsp:setProperty name="simple" property="age" value="24" />
    </jsp:useBean>
    
    <%-- Displaying JavaBean property's value --%>
    <p>Name retrieved from JavaBean has the value of : 
    	<b><jsp:getProperty name="simple" property="name" /></b>.<br>
    Age retrieved from JavaBean has the value of :
    	<b><jsp:getProperty name="simple" property="age" /></b> years.<br>
    </p>
    
    </body>
    </html>
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice