<%@ page import="beans.NameBean"  %>

<jsp:useBean id="pageBean" class="beans.NameBean" scope="page" />
<jsp:setProperty name="pageBean" property="*" />

<jsp:useBean id="sessionBean" class="beans.NameBean" scope="session" />
<jsp:setProperty name="sessionBean" property="*" />

<HTML>
<HEAD> <TITLE> The UseBean JSP </TITLE> </HEAD>
<BODY BGCOLOR=white>

<H3> Welcome to the UseBean JSP </H3>
<P><B>Page bean: </B>
<% if (pageBean.getNewName().equals("")) { %>
  I don't know you. 
<% } else { %>
  Hello <%= pageBean.getNewName() %> !
<%  } %> 
  
<P><B>Session bean: </B>
<% if (sessionBean.getNewName().equals("")) { %>
  I don't know you either. 
<% } else {
       if ((request.getParameter("newName") == null) || 
           (request.getParameter("newName").equals(""))) { %>
         Aha, I remember you.   
<%     } %>   
       You are <%= sessionBean.getNewName() %>.
<% } %>

<P>May we have your name?
<FORM METHOD=get>
<INPUT TYPE=TEXT name=newName size = 20>
<INPUT TYPE=SUBMIT VALUE="Submit name">
</FORM>
</BODY>
</HTML>
