
<%@ page contentType="text/html;charset=GB2312" %>
<%! //处理字符串的方法：
  public String codeString(String s)
    { String str=s;
       try{byte b[]=str.getBytes("ISO-8859-1");
           str=new String(b);
           return str;
         }
      catch(Exception e)
         { return str;
         }
    }
%>
<HTML>
<BODY ><Font size=1>
<%@ include file="head.jsp" %>
<Font size=1>
<%String str=response.encodeURL("userRegister.jsp");
%>
<P>输入您的信息，带*号项必须填写：
<FORM action="<%=str%>" Method="post">
<BR>登录名称<Input type=text name="logname">*
<BR>真实姓名<Input type=text name="realname">*
<BR>设置密码<Input type=password name="password">*
<BR>电子邮件<Input type=text name="email">*
<BR>联系电话<Input type=text name="phone">*
<BR>通信地址<Input type=text name="address">*
<BR><Input type=submit name="g" value="提交">
</Form>
<jsp:useBean id="login" class="a1.Register" scope="request" >
</jsp:useBean>
 <% //提交信息后，进行注册操作：
   String logname="",realname="",password="",email="",phone="",address="";
   if(!(session.isNew()))
    { logname=request.getParameter("logname");
      if(logname==null)
        {logname="";
        }
     logname=codeString(logname);
     realname=request.getParameter("realname");
       if(realname==null)
        {realname="";
        }
     realname=codeString(realname);
     password=request.getParameter("password");
         if(password==null)
        {password="";
        }
     password=codeString(password);
     email=request.getParameter("email");
         if(email==null)
        {email="";
        }
     email=codeString(email); 
     phone=request.getParameter("phone");
         if(phone==null)
        {phone="";
        }
     phone=codeString(phone); 
     address=request.getParameter("address");
        if(address==null)
        {address="";
        }
     address=codeString(address); 
   }
 %>
 <%   //为了以后处理汉字方便，我们采用了第1种方式初始化beans
   if(!(logname.equals(""))&&!(address.equals(""))&&!(phone.equals(""))
        &&!(realname.equals(""))&&!(password.equals("")))
   {%> 
     <jsp:setProperty  name= "login"  property="logname"  value="<%=logname%>" />
     <jsp:setProperty  name= "login"  property="realname" value="<%=realname%>" />
     <jsp:setProperty  name= "login"  property="password"  value="<%=password%>" />
     <jsp:setProperty  name= "login"  property="email" value="<%=email%>" />
     <jsp:setProperty  name= "login"  property="phone"  value="<%=phone%>" />
     <jsp:setProperty  name= "login"  property="address" value="<%=address%>" />
    <% 
     login.addItem();
    }
   else
    {out.print("你还没有填写信息，或信息填写不完整");
    }
 %>
  <% //返回注册信息
     if(!(session.isNew()))
    {
  %>
    <jsp:getProperty  name= "login"  property="message" />
  <%
    } 
 %>
</Body>
</HTML>
