jsp表单的提交与显示,我弄的提交后有错误,各位看看!
longin.jsp
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>My Frist JSP Web</title>
<style type="text/css">
  <
  h1       {font: 15pt/17pt "Arial"; font-weight: bold; color:maroon}
    body {
        background-color:#FFFBF0
     }
  .STYLE1 {font-size: x-large}
  >
</style>
</head>
<body>
<H1 align="center" class="STYLE1" >欢迎各位光临!</H1>
<form action="logins.jsp" method="post" name="form1">
   <p><center>
      登陆姓名:
      <input name="name" type="text" /></center>
   </p>
   <p><center>
      登陆密码:
     <input name="password" type="password" /></center></p>
   <p><center> 
      <input name="ok" type="submit" value="确认" />     
       <input name="back" type="submit" value="重置" />
   </center>
   </p>
  
</form> 
</body>
</html>
logins.jsp
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body><pre>
<%
String na=request.getParameter("name");
String  pa=request.getParameter("password");
if(name==null||password==null)out.println("很抱歉,你没有输入正确!");
  else
 { 
out.println("你的姓名:");
out.println(na);
out.println("您的密码:");
out.println(pa);
    }
%>
</body>
</html>

解决方案 »

  1.   


    <!--type="reset"-->
    <input name="back" type="submit" value="重置" />
      

  2.   

    String na=request.getParameter("name");
    String pa=request.getParameter("password");
    if(name==null||password==null)out.println("很抱歉,你没有输入正确!");
    改成
    if(na==null||pa==null)
    不会是这么初级的错误吧
      

  3.   

    真是这个初级错误,我经常犯的,看了tomcat的错误,就写了这个错误,我没注意.......我这个无语了,写的快了,没注意,谢谢你了!
      

  4.   

    String na=request.getParameter("name");
    String pa=request.getParameter("password");
    if(name==null||password==null)out.println("很抱歉,你没有输入正确!");
    LZ好好看看吧,这也太粗心了
      

  5.   

    谢谢各位啊,改了以后的:
    longin.jsp
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>My Frist JSP Web</title>
    <style type="text/css">
      <
      h1 {font: 15pt/17pt "Arial"; font-weight: bold; color:maroon}
       body {
       background-color:#FFFBF0
     }
       .STYLE1 {font-size: x-large}
      >
    </style>
    </head>
    <body>
    <H1 align="center" class="STYLE1" >欢迎各位光临!</H1>
    <form action="logins.jsp" method="post" name="form1">
       <p><center>
       登陆姓名:
       <input name="name" type="text" /></center>
       </p>
       <p><center>
       登陆密码:
       <input name="password" type="password" /></center></p>
       <p><center> 
       <input name="ok" type="submit" value="确认" />     
       <input name="back" type="submit" value="重置" />
       </center>
       </p>
        
    </form>  
    </body>
    </html>
    logins.jsp
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <% 
     request.setCharacterEncoding("gb2312"); 
     %>
    <title>无标题文档</title>
    </head><body><pre>
    <%
    String na=request.getParameter("name");
    String  pa=request.getParameter("password");
    if(na==null||pa==null)out.println("很抱歉,你没有输入!");
      else
     { 
    out.println("你的姓名:");
    out.println(na);
    out.println("您的密码:");
    out.println(pa);
        }
    %>
    </body>
    </html>