%-- Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. This software is the proprietary information of Sun Microsystems, Inc. Use is subject to license terms. --%> <%@ page import="converter.Converter, converter.ConverterHome, javax.ejb.*, java.math.*, javax.naming.*, javax.rmi.PortableRemoteObject, java.rmi.RemoteException" %> <%! private Converter converter = null; public void jspInit() { try { InitialContext ic = new InitialContext(); Object objRef = ic.lookup("java:comp/env/ejb/TheConverter"); ConverterHome home = (ConverterHome)PortableRemoteObject.narrow(objRef, ConverterHome.class); converter = home.create(); } catch (RemoteException ex) { System.out.println("Couldn't create converter bean."+ ex.getMessage()); } catch (CreateException ex) { System.out.println("Couldn't create converter bean."+ ex.getMessage()); } catch (NamingException ex) { System.out.println("Unable to lookup home: "+ "TheConverter "+ ex.getMessage()); } } public void jspDestroy() { converter = null; } %>
Enter an amount to convert:
<% String amount = request.getParameter("amount"); if ( amount != null && amount.length() > 0 ) { BigDecimal d = new BigDecimal (amount); %><%= amount %> dollars are <%= converter.dollarToYen(d) %> Yen.
<%= amount %> Yen are <%= converter.yenToEuro(d) %> Euro. <% } %>