Listing 4. calculator.jsp

<HTML>
<Head><Title>Calculator</Title></Head>

<jsp:useBean id="calculator"
 class="il.co.lerner.Calculate"/>

<Body>
<H1>Simple calculator</H1>

<jsp:setProperty name="calculator" property="*"/>

<P>Setting arg1 to <jsp:getProperty name="calculator"
 property="arg1"/>.</P>
<P>Setting arg2 to <jsp:getProperty name="calculator"
 property="arg2"/>.</P>

<P>Sum: <jsp:getProperty name="calculator"
 property="sum"/></P>

<P>Quotient:
    <% try { %>
        <jsp:getProperty name="calculator"
         property="quotient"/>
    <% } catch (Exception e) { %>
        <B>Error! division by zero</B>
    <% } %>
</P>

<P>Difference: <jsp:getProperty name="calculator"
 property="difference"/></P>

</Body>
</HTML>