<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="name.jsp" %>
<jsp:useBean id="DBConnection" scope="page" class="com.raecom.DBConnection"/>
<%
String Useradmin = (String)session.getValue("admin");
Boolean a=(Boolean)session.getAttribute("a"); 
Connection conn=DBConnection.getConnectionToAccess(application.getRealPath("data/RAE-Systems.mdb"));
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); 
if(a==null||a.booleanValue()==false)
{
%>
<script language=JavaScript>
alert('此页面仅对登录用户开放!');
location.href="index.jsp"
</script>
<%
}else{
String admin=request.getParameter("admin");
if (admin==null)
{
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改管理信息</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function check(){   
if(post.admin.value==""){
alert("请输入您的用户名");
return false;
}
if(post.admin.value.length>30){
alert("用户名位数不超过15");
return false;
}


if(post.password.value==""){
alert("请输入密码");
return false;
}
if(post.password.value.length>50){
alert("密码位数不超过24");
return false;
}

if(post.password2.value==""){
alert("请输入重复密码");
return false;
}
if(post.password2.value.length>50){
alert("重复密码位数不超过24");
return false;
}


if(post.password.value!=post.password2.value){
alert("输入的两次密码不一致");
return false;
}
return true;
}
</script>
<SCRIPT src="images/index.js"></SCRIPT>
</head>
<body>
<jsp:include page="top.htm" />
<table cellspacing=0 cellpadding=0 width=760 align=center border=0 bgcolor="#FFFFFF">
  <tr> 
      <td width="200" valign=top>
       <jsp:include page="left.jsp" />
      </td>
        <td valign=top class="tdbg_leftall"> 
        <table cellspacing=0 cellpadding=0 border=0>
        <tr> 
          <td valign=top> 
            <table cellspacing=0 cellpadding=0 width="100%" align=center border=0>
              <tr> 
                <td></td>
              </tr>
              <tr> 
                <td valign="top">
                  <table width="100%" border="1" cellspacing="0" cellpadding="0" align="center"    style=":break-all;font-family: Arial, Helvetica, sans-serif;">
                    <tr> 
                            <td width="560"> 
  <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
                                <tr> 
                                  <td height="28"><table border="1" width="100%" cellspacing="0" cellpadding="0"  align="center" bgcolor="#4791C5"   >
                                      <tr> 
                                          <td width="100%" height="24">
<p align="center">
<font color="#FFFFFF">...::修改管理信息::...</font></td>
                                      </tr>
                                    </table>
                                    <%
   String sql="select * from employee where Use_Name='"+Useradmin+"'"; 
   ResultSet Rs=stmt.executeQuery(sql);
      while(Rs.next())
   {
%>
<form action="config.jsp?" method="post" name="post" id="post" onsubmit="return check();">
<table border="0" width="260" id="table1" align="center">
<tr>
<td>
<p align="right">用户帐号:</td>
<td> &nbsp;<INPUT 
                  name="admin" id="admin" value=<%=Rs.getString("Use_Name")%> size=18></td>
</tr>
<tr>
<td>
<p align="right">用户密码:</td>
<td><span class="f12">
&nbsp;</span><INPUT type=password size=19 
                  value=<%=Rs.getString("Password")%> name="password"></td>
</tr>
<tr>
<td>
<p align="right">重 复 密码:</td>
<td>
         &nbsp;<INPUT type=password size=19 
                  value=<%=Rs.getString("Password")%> name="password2"></td>
</tr>
<tr>
<td colspan="2">
         <p align="center">
         <INPUT type=submit value="确认修改" name=Submit> &nbsp;&nbsp; <INPUT type=reset value="清 除" name=Submit2>
</td>
</tr>
</table>
</form>
<%  }  %>   
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      </td>
  </tr>
</table>
      </td>
  </tr>
</table>
      </td>
  </tr>
</table>
</body>
</html>
<%
}
else
{
  String password=request.getParameter("password");
  String  sql1="update employee set Use_Name='"+admin+"',Password='"+password+"' where Use_Name='"+Useradmin+"'"; 
try{
        stmt.executeUpdate(sql1);
session.invalidate();
%>
<script language=JavaScript>
alert('修改成功,请使用新身份重新登陆系统进行管理!');
location.href="login.jsp"
</script>
<%
}catch(Exception e)
     {
   response.sendRedirect("error.jsp?error=2");//数据库更新出错!
 }
 
}
if(conn!=null)
{
conn.close();
}
if(stmt!=null)
{
stmt.close();
}
}
%>

解决方案 »

  1.   

    你先检查一下生成的页面的源代码是什么,贴出来看看程序解释到了哪一步了!    还有,建议不使用这个方法: (String)session.getValue("admin");
      

  2.   

    看看跟这个有关系没?<%@ include file="name.jsp" %>
      

  3.   

    楼上的各位老大你们好,这段代码是我从别的程序copy过来后修改的,原程序可以运行,我只是改了两个地方。
    本来我怀疑是String admin=request.getParameter("admin");的admin值本来就有,admin!=null所以不生成下面的table, 但是除了表格别的又都可以显示。连...::修改管理信息::... 也在,所以我怀疑是 <%
       String sql="select * from employee where Use_Name='"+Useradmin+"'";  ResultSet Rs=stmt.executeQuery(sql);
    while(Rs.next()) {
    %>
    <form action="config.jsp?" method="post" name="post" id="post" onsubmit="return check();">。。//生成表单
    上有问题,不知道大家有没碰到过这样的事情。
      

  4.   

    解决了,哥哥们~谢啦,是我一个session没传对~