<%@ page import="javax.naming.*, javax.rmi.PortableRemoteObject, SayMyName, SayMyNameHome"%> <%@ page session="true"%> <%! SayMyName sayMyName = null; public void jspInit() { try { InitialContext initialContext = new InitialContext(); Object initialContextObject = initialContext.lookup("java:comp/env/ejb/TheSayMyName"); SayMyNameHome sayMyNameHome = (SayMyNameHome)PortableRemoteObject.narrow( initialContextObject, SayMyNameHome.class); sayMyName = sayMyNameHome.create(); } catch (java.rmi.RemoteException remoteException) { System.out.println("Couldn't create SayMyName bean."+ remoteException.getMessage()); } catch (javax.ejb.CreateException createException) { System.out.println("Couldn't create SayMyName bean."+ createException.getMessage()); } catch (NamingException namingException) { System.out.println("Unable to lookup home TheSayMyName "+ namingException.getMessage()); } } %> <% session.setAttribute("SayMyName", sayMyName); %> Your Name

Please Type Your Name:

<% String yourName = request.getParameter("yourName"); sayMyName.setMyName(yourName); %> <% String encodedSessionURL = response.encodeURL("SayMyName.jsp"); %> <% String href = "a " + "href"; %> <<%= href %>="<%= encodedSessionURL %>"> ...on to Say My Name!