
<%@ 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 string=response.encodeURL("userLogin.jsp");
%>
<P>输入用户名和密码：
<FORM action="<%=string%>" Method="post">
<BR>登录名称<Input type=text name="logname">
<BR>输入密码<Input type=password name="password">
<BR><Input type=submit name="g" value="提交">
</Form>
<jsp:useBean id="login" class="a1.Login" scope="session" >
</jsp:useBean>
 <% //提交信息后，验证信息是否正确：
   String  message="",
           logname="",
           password="";
    if(!(session.isNew()))
    {logname=request.getParameter("logname");
        if(logname==null)
           {logname="";
           }
     logname=codeString(logname);
     password=request.getParameter("password");
        if(password==null)
           {password="";
           }
     password=codeString(password);
   }
 %>
 <%
   if(!(logname.equals("")))
    {
   %>
     <jsp:setProperty  name= "login"  property="logname"  value="<%=logname%>" />
     <jsp:setProperty  name= "login"  property="password"  value="<%=password%>" />
   <%
     message=login.getMessage();
        if(message==null)
          {message="";
          }  
   }
 %>
 <%  if(!(session.isNew()))
      { if(message.equals("ok"))
          { String str=response.encodeURL("buybook.jsp");
            response.sendRedirect(str); 
          }
        else
          {out.print(message);
          }
      }
  %>
</Body>
</HTML>