<%@ page import="converter.ejb.Converter, java.math.*, javax.naming.*"%> <%! private Converter converter = null; public void jspInit() { try { InitialContext ic = new InitialContext(); converter = (Converter) ic.lookup(Converter.class.getName()); } catch (Exception ex) { System.out.println("Couldn't create converter bean."+ ex.getMessage()); } } public void jspDestroy() { converter = null; } %> Converter

Converter


Enter an amount to convert:


<% String amount = request.getParameter("amount"); if ( amount != null && amount.length() > 0 ) { BigDecimal d = new BigDecimal(amount); BigDecimal yenAmount = converter.dollarToYen(d); %>

<%= amount %> dollars are <%= yenAmount %> Yen.

<% BigDecimal euroAmount = converter.yenToEuro(yenAmount); %> <%= yenAmount %> Yen are <%= euroAmount %> Euro. <% } %>