<%@ page import="Converter,ConverterHome,javax.ejb.*, 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) { ex.printStackTrace(); } catch (javax.naming.NamingException nmex) { nmex.printStackTrace() ; } catch (javax.ejb.CreateException crex) { crex.printStackTrace(); } } %> Converter

Converter


Enter an amount to convert:


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

<%= amount %> dollars are <%= converter.dollarToYen(d.doubleValue()) %> Yen.

<%= amount %> Yen are <%= converter.yenToEuro(d.doubleValue()) %> Euro. <% } %>