response.sendRedirect("../Index.htm");

解决方案 »

  1.   

    <jsp:forward page="xx.jsp"/>
      

  2.   

    userLogin.jsp源代码:
    <%@ page contentType="text/html;charset=gb2312" language="java" import="java.sql.*,java.util.Date" errorPage="" %>
    <HTML>
    <HEAD>
    <TITLE>欢迎光临高中会考网站</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=gb2312">
    <style type="text/css">
    td, p, li {font-family:宋体;font-size:9pt;}
    A {TEXT-DECORATION: none; TEXT-TRANSFORM: none}
    A:link {text-decoration: none; color: #333333;font-size:9pt}
    A:visited {text-decoration: none; color: #333333;font-size:9pt}bb
    A:active {text-decoration: underline;font-size:9pt}
    A:hover {text-decoration: underline; color: #FF8300;font-size:9pt}
    .unnamed1 {
    font-size: 9pt;
    line-height: 9pt;
    }
    </style>
    <LINK href="../Script/my_style.css" type=text/css rel=stylesheet>
    <SCRIPT language=javascript src="../Script/bar_ctrl.js"></SCRIPT>
    <SCRIPT language=javascript src="../Script/bar_init.js"></SCRIPT></HEAD><script language="javascript">
    function FN_Check()
    {
    if(document.sub.logname.value == "")
    {
    alert("登录名不能为空,请重新输入!");
    document.sub.logname.focus();
    return false;
    }
    if(document.sub.password.value == "")
    {
    alert("密码不能为空,请重新输入!");
    document.sub.password.focus();
    return false;
    }
    return  true;
    }
    </script><BODY leftMargin=0 topMargin=0 onload=init(); bgproperties="fixed" background="../Images/Main_bg.gif">
      <div align="center">
        <center>
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="756" height="10" id="AutoNumber1" bgcolor="#FFFFFF">
        <tr> 
          <td height="10" bordercolor="#000000" valign="bottom" background="../Images/Main_top.gif" width="756" style="border-left:1px solid #000000; border-right:1px solid #000000; font-family: 宋体; font-size: 9pt"></td>
        </tr>
      </table>
        </center>
      </div>
      <div align="center">
        <center>
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="756" height="60" id="AutoNumber1" background="../Images/Top_bg.jpg" bgcolor="#336699">
        <tr> 
          <td height="60" bordercolor="#000000" valign="bottom" width="11" style="font-family: 宋体; font-size: 9pt; border-left-style:solid; border-left-width:1; border-right-width:1; border-top-width:1; border-bottom-width:1"> </td>
            <td height="60" bordercolor="#000000" valign="bottom" width="473" style="font-family: 宋体; font-size: 9pt">&nbsp;</td>
          <td height="60" bordercolor="#000000" width="13" style="font-family: 宋体; font-size: 9pt; border-left-width:1; border-right-style:solid; border-right-width:1; border-top-width:1; border-bottom-width:1">
           </td>
        </tr>
        </table>
        </center>
      </div>
      

  3.   

    <!--/////////////////导航条代码开始//////////////////-->
            <div align="center">
              <center>
            <table cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-left-style:solid; border-left-width:1; border-right-style:solid; border-right-width:1; border-top-width:1; border-bottom-width:1" bordercolor="#111111" width="756" height="18" id="AutoNumber5" background="../Images/Menu/idx_bar_p.gif">
              <tr> 
                <td width="19" height="18" background="../Images/Menu/idx_bar_b.gif" style="border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: solid; border-bottom-width: 1" bordercolor="#808080"> 
                 </td>
                <td width="101" background="../Images/Menu/idx_bar_b.gif" style="border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: solid; border-bottom-width: 1" bordercolor="#808080" valign="top"> 
                  <img border="0" src="..\Images/logo_bottom.gif" width="83" height="12"></td>
                <td width="100" background="../Images/Menu/idx_bar_b.gif" style="border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: solid; border-bottom-width: 1" bordercolor="#808080"> 
                  <a href="file:///C|/Tomcat4/webapps/ROOT/britney/Index.htm"> 
                  <img id=button0 border="0" src="..\Images/Menu/i_bar_0a.gif" name=button0 align="left" width="100" height="25"></a></td>
                
            <td width="100" background="../Images/Menu/idx_bar_b.gif" style="border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: solid; border-bottom-width: 1" bordercolor="#808080"> 
              <font color="#666666"> <a id="menu1" href="div_th.htm"> <img id=button1 border="0" src="..\Images/Menu/i_bar_1a.gif" name=button1 width="100" height="25"></a></font></a></font></td>
                <td width="100" background="../Images/Menu/idx_bar_b.gif" style="border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: solid; border-bottom-width: 1" bordercolor="#808080"> 
                  <a id="menu2" href="div_ds.htm"> 
                  <font color="#666666"> 
                  <img id=button2 border="0" src="..\Images/Menu/i_bar_4a.gif" name=button2 width="100" height="25"></font></a></font></td>
                <td width="100" background="../Images/Menu/idx_bar_b.gif" style="border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: solid; border-bottom-width: 1" bordercolor="#808080"> 
                  <a id="menu3" href="div_cd.htm"> 
                  <font color="#666666"> 
                  <img id=button3 border="0" src="..\Images/Menu/i_bar_5a.gif" name=button3 width="100" height="25"></font></a></font></td>
                <td width="100" background="../Images/Menu/idx_bar_b.gif" style="border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: solid; border-bottom-width: 1" bordercolor="#808080"> 
                  <a id="menu4" href="div_pr.htm"> 
                  <font color="#666666"> 
                  <img id=button4 border="0" src="..\Images/Menu/i_bar_6a.gif" name=button4 width="100" height="25"></font></a></font></td>
                <td width="100" background="../Images/Menu/idx_bar_b.gif" style="border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: solid; border-bottom-width: 1" bordercolor="#808080"> 
                  <a id="menu5" href="div_sc.htm"> 
                  <font color="#666666"> 
                  <img id=button5 border="0" src="..\Images/Menu/i_bar_7a.gif" name=button5 width="100" height="25"></font></a></font></td>
                <td width="36" background="../Images/Menu/idx_bar_b.gif" style="border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-style: solid; border-bottom-width: 1" bordercolor="#808080"> 
                 </td>
              </tr>
            </table>
              </center>
      </div>
      <center>
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-left-style:solid; border-left-width:1; border-right-style:solid; border-right-width:1; border-top-width:1; border-bottom-width:1" bordercolor="#111111" width="756" height="511" id="AutoNumber1" bgcolor="#FFFFFF">
        <tr> 
          <td height="1" colspan="5" bordercolor="#000000" width="756">         <SCRIPT language=javascript src="../Script/bar_cont.js"></SCRIPT> 
    <!--/////////////////导航条代码结束//////////////////-->
      

  4.   

    转向上一层目录下的Index.htm页面,如果你的Index.htm与userLogin.jsp不在同一个文件夹中,而在不同的文件夹中的话,要使用response.sendRedirect("../dou/Index.htm");
    dou代表你存放Index.htm的文件夹名。
      

  5.   

    谢谢,我换了一下,转向同级页面也不行。真是诡异。可不可以帮我看看我的代码,是不是太冗长了,调用的资源太多而导致的?继续贴上面的代码: </td>
        </tr>
        <tr> 
          <td height="50" colspan="5" bordercolor="#000000" valign="bottom" background="../Images/Greybar1.gif" width="756"></td>
        </tr>
        <tr> 
          <td height="361" bordercolor="#000000" width="20" rowspan="6"> </td>
          <td height="21" bordercolor="#000000" width="728" colspan="4" valign="middle">
          <a href="index.htm">首页</a>&gt;&gt;</td>
        </tr>
        <tr> 
          <td height="314" bordercolor="#000000" width="143" align="center" valign="top" rowspan="4">
          <iframe name="I1" scrolling="no" border="0" frameborder="0" width="155" height="90" src="..\Modules/Logon.htm" target="_parent">
          您的浏览器不支持嵌入式框架。</iframe> 
          <iframe name="I6" scrolling="no" border="0" frameborder="0" width="155" height="110" src="..\Modules/Score.htm" target="_parent"> 
          您的浏览器不支持嵌入式框架。</iframe> 
            <iframe name="I6" scrolling="no" border="0" frameborder="0" width="155" height="115" src="..\Modules/Application.htm" target="_parent"> 
          您的浏览器不支持嵌入式框架。</iframe></td> 
          <td height="312" bordercolor="#000000" width="44" rowspan="4" valign="top" background="../Images/line02.gif">
           </td>
          <td height="27" bordercolor="#000000" width="462" valign="top"> <p style="line-height: 150%"> 
              <b><font size="3" color="#333333"> <img border="0" src="..\Images/Title_front.gif" width="12" height="12"></font><font size="2" color="#555555"> 
              用户登陆</font></b>
    <hr style="height: 5px">
          </td>
          <td height="340" bordercolor="#000000" width="58" rowspan="5" background="../Images/line02.gif"> </td>
        </tr>
        <tr>
          <td height="272" bordercolor="#000000" width="462" valign="top"> 
            <form method="POST" name="sub">
            <P>&nbsp;</P>
              <P align="center">&nbsp;&nbsp;<font size="2"> 用户名:  
                <input type="text" name="logname" size="20">
                </font></P>
              <P align="center"><font size="2">&nbsp;&nbsp;&nbsp;密&nbsp; 码:  
                <input type="password" name="password" size="20">
                </font></P>
              <P align="center"><font size="2">用户类型:  
                &nbsp;<input type="radio" name="usersort" value="admin">
                管理员</font></P> 
              <P align="center"><font size="2">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;   
                <input type="radio" name="usersort" value="staff">
                工作人员</font></P> 
              <P align="center"><font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;  
                <input type="radio" name="usersort" value="student" checked>
                考生</font></P> 
            <CENTER>
              <P align="center"><font size="3"><font color="#666666" size="2">&nbsp;找回密码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 新用户注册</font></font></P> 
              <P align="center">
                <input type="submit" value="提交" name="g" onclick="return FN_Check();">
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        <input type="reset" value="取消" name="B2">
              </P>
            </center>
          </form>
            </td>
          </tr>    <tr>
          <td height="18" bordercolor="#000000" width="462" valign="top"> 
            <p style="line-height: 150%"><font color="#555555"> 
              </font><font color="#555555"> </font></td>
          </tr>
        <tr> 
          <td height="18" bordercolor="#000000" align="center" width="681" colspan="3"> 
            <p style="line-height: 150%"> </td>
        </tr>
        <tr> 
          <td height="38" colspan="5" bordercolor="#000000" align="center" width="756"> 
          <iframe name="I5" target="_parent" scrolling="no" border="0" frameborder="0" width="720" height="30" src="..\Modules/Bottom.htm" align="center">
          您的浏览器不支持嵌入式框架。</iframe></td>
        </tr>
        <tr> 
          <td height="17" colspan="5" bordercolor="#000000" align="center" bgcolor="#333333" width="756"> 
         td> 
        </tr>
      </table>
    </center>
      </BODY></HTML>
      

  6.   

    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:beibei";
    Connection con=DriverManager.getConnection(url);
    out.print("数据库连接成功,恭喜你");Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String usersort = request.getParameter("usersort");
    String logname = request.getParameter("logname");
    //String password = request.getParameter("password");if(usersort!=null&&logname!=null)
    {
    String sql="select password from " + usersort + " where logname = '" + logname + "'";
    out.print(sql);
    ResultSet rs=stmt.executeQuery(sql); 
    if(rs.next()) 
    {   //out.print("数据库连接成功,恭喜你");
               
                 response.sendRedirect("../Index.htm");
        //String str=response.encodeRedirectURL("student.jsp");
    //response.sendRedirect("str"); 
    }
    else

         out.print("用户名或者密码错误,请重新输入!"); 
    }
    rs.close();

    stmt.close(); 
    con.close();
    %>
    <完〉
      

  7.   

    <form action="date.jsp" method="POST" name="sub">
    __________________________________________________
    注意这:你的表单似乎没有提交
              <P>&nbsp;</P>
              <P align="center">&nbsp;&nbsp;<font size="2"> 用户名:  
                <input type="text" name="logname" size="20">
                </font></P>
              <P align="center"><font size="2">&nbsp;&nbsp;&nbsp;密&nbsp; 码:  
                <input type="password" name="password" size="20">
                </font></P>
              <P align="center"><font size="2">用户类型:  
                &nbsp;<input type="radio" name="usersort" value="admin">
                管理员</font></P> 
              <P align="center"><font size="2">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;   
                <input type="radio" name="usersort" value="staff">
                工作人员</font></P> 
              <P align="center"><font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;  
                <input type="radio" name="usersort" value="student" checked>
                考生</font></P> 
            <CENTER>
              <P align="center"><font size="3"><font color="#666666" size="2">&nbsp;找回密码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 新用户注册</font></font></P> 
              <P align="center">
                <input type="submit" value="提交" name="g" onclick="return FN_Check();">
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        <input type="reset" value="取消" name="B2">
              </P>
            </center>
          </form>
      

  8.   

    谢谢楼上的,把输出到浏览器的去掉了,还是不行。我做了一个简单的糙页面<%@ page contentType="text/html;charset=GBK" language="java" import="java.sql.*,java.util.Date" errorPage="" %>
    <html>
    <head>
    </head><script language="javascript">
    function FN_Check()
    {
    if(document.sub.logname.value == "")
    {
    alert("登录名不能为空,请重新输入!");
    document.sub.logname.focus();
    return false;
    }
    if(document.sub.password.value == "")
    {
    alert("密码不能为空,请重新输入!");
    document.sub.password.focus();
    return false;
    }
    return  true;
    }
    </script><BODY>       <form method="POST" name="sub">
           <P>&nbsp;&nbsp;&nbsp; <font size="3">用户名</font>:
           <input type="text" name="logname" size="20"></P>         
            <P>&nbsp;&nbsp;&nbsp;&nbsp; <font size="3">密&nbsp; 码</font>:
           <input type="password" name="password" size="20"></P></CENTER>
            <P><font size="2">用户类型:
           <input type="radio" name="usersort" value="admin" >管理员</font></P><P><font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     
           <input type="radio" name="usersort" value="staff" >工作人员</font></P><P><font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     
           <input type="radio" name="usersort" value="student" checked>考生</font></P>
    <CENTER>
    <P align="center"><font size="3"><font color="#0000FF">&nbsp;找回密码&nbsp;</font>&nbsp;&nbsp;&nbsp;&nbsp;
    <font color="#0000FF"> 新用户注册</font></font></P></center></TD></TR>        
       <TR>
         <TD vAlign=top borderColor=#000000 width=625 height=48 align="center">
           <input type="submit" value="提交" name="g" onclick="return FN_Check();"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     
             <input type="reset"  value="取消" name="B2">
            </TD></TR>
          </form>
    </BODY></HTML>
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:beibei";
    Connection con=DriverManager.getConnection(url);
    out.print("数据库连接成功,恭喜你");Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String usersort = request.getParameter("usersort");
    String logname = request.getParameter("logname");if(usersort!=null&&logname!=null)
    {
    String sql="select password from " + usersort + " where logname = '" + logname + "'";
    out.print(sql);
    ResultSet rs=stmt.executeQuery(sql); 
    if(rs.next()) 
    {
    response.sendRedirect("student.jsp");
    }
    else
    {
             out.print("密码错误");
    }
    rs.close();

    stmt.close(); 
    con.close();%>这次到成功了,但是为什么在我原来的页面里面就不行呢?代码是完全一样的阿。郁闷死我了:(
      

  9.   

    chaozi(编程浪子) ,谢谢GG,没有提交?那要怎么改呢?
      

  10.   

    新建一个JSP 如命名为LoginTemp.jsp,在这个页面进行验证:
    Login.jsp:
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:beibei";
    Connection con=DriverManager.getConnection(url);
    out.print("数据库连接成功,恭喜你");Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String usersort = request.getParameter("usersort");
    String logname = request.getParameter("logname");if(usersort!=null&&logname!=null)
    {
    String sql="select password from " + usersort + " where logname = '" + logname + "'";
    out.print(sql);
    ResultSet rs=stmt.executeQuery(sql); 
    if(rs.next()) 
    {
    response.sendRedirect("student.jsp");
    }
    else
    {
             out.print("密码错误");
    }
    rs.close();

    stmt.close(); 
    con.close();%>
      

  11.   

    应该是LoginTemp.jsp:
    表单提交到LoginTemp.jsp页面表单提交改为
    <form action="date.jsp" method="POST" name="sub">
    __________________________________________________
    既增加action方法。
      

  12.   

    应该是LoginTemp.jsp:
    表单提交到LoginTemp.jsp页面表单提交改为
    <form action="LoginTemp.jsp" method="POST" name="sub">
    __________________________________________________
    既增加action方法