请高手指教这是什么错误 description The server encountered an internal error () that prevented it from fulfilling this request.

qingyun9833 2006-10-11 11:24:32
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception


root cause

java.lang.NoSuchMethodError: mydesign.AdminControl.isAdmin(Lmydesign/Admin;)Z
mydesign.UpdatePWD.doPost(UpdatePWD.java:45)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.28
...全文
478 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
neptune0229 2006-10-11
  • 打赏
  • 举报
回复
public String isAdmin(Admin admin) throws Exception
if(admincontrol.isAdmin(admin))
这两个冲突了,返回值是String的,不能用if直接判断
qingyun9833 2006-10-11
  • 打赏
  • 举报
回复
/**
* UpdateAdmin.java
* author:liuhaijing
* @version 1.0
*/

package mydesign;//包名

import java.io.*;
import mydesign.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class UpdateAdmin extends HttpServlet
{

//Initialize global variables
public void init() throws ServletException
{
}

//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
HttpSession session=request.getSession(true);
request.setCharacterEncoding("gb2312");
response.setContentType("text/html; charset=gb2312");
PrintWriter out = response.getWriter();

Admin admin=(Admin)session.getAttribute("admin1");
AdminControl admincontrol=new AdminControl();

String password=request.getParameter("password");

//处理数据
try
{
admin.setPassword(password);
admincontrol.UpdateAdmin(admin);
admincontrol.close();
session.setAttribute("admin1",null);
out.print("<script>alert('成功修改!');window.location.href='/MyDesign/SearchAdmin'</script>");
}
catch(Exception e)
{
System.out.print("UpdateAdminServlet error:"+e.getMessage());
}
finally
{
}
}

//Clean up resources
public void destroy()
{
}
}
qingyun9833 2006-10-11
  • 打赏
  • 举报
回复
/*
*Admin.java
*author:liuhaijing
*Hainan university
*/


package mydesign;

import java.io.*;
import java.util.*;

public class Admin{

public String username;
public String password;
public String manage;

//default Fuction
public Admin()
{
}


//setter
public void setManage(String manage)
{
this.manage=manage;
}
public void setUserName(String name)
{
this.username=name;
}
public void setPassword(String pwd)
{
this.password=pwd;
}


//getter
public String getManage()
{
return this.manage;
}
public String getUserName()
{
return this.username;
}
public String getPassword()
{
return this.password;
}
}
qingyun9833 2006-10-11
  • 打赏
  • 举报
回复
/*
*AdminControl.java
*author:liuhaijing
*/

package mydesign;

import mydesign.*;
import java.sql.*;
import java.io.*;
import java.util.*;//Vector在这个包里
import mydesign.*;
public class AdminControl
{

ResultSet rs=null;
String sql=null;
DBConnect dbconnect=new DBConnect();

public AdminControl()
{
}

public String isAdmin(Admin admin) throws Exception
{
String a=null;
sql="select * from admin where username='"+admin.getUserName()+"' and password='"+admin.getPassword()+"';";
rs=dbconnect.executeQuery(sql);
if(rs.next())
{
a=new String(rs.getString("manage").getBytes("iso-8859-1"));
}
rs.close();
return a;
}

//add the admin
public void addAdmin(Admin admin)
{
try
{
sql="insert into admin (username,password,manage) values ('"+admin.getUserName()+"','"+admin.getPassword()+"','"+admin.getManage()+"');";
dbconnect.executeUpdate(sql);
}
catch(Exception ex)
{
System.out.print("AddAdmin Bean error:"+ex.getMessage());
}
}



public ArrayList getAllAdmin()
{

ArrayList a=new ArrayList();
try
{
sql="select * from admin;";
rs=dbconnect.executeQuery(sql);
while(rs.next())
{
Admin admin=new Admin();
admin.setManage(rs.getString("manage"));
admin.setPassword(rs.getString("username"));
admin.setUserName(rs.getString("password"));
a.add(admin);
}
rs.close();
}catch(Exception ex)
{
System.out.print("AdminControl's allAdmin error:"+ex.getMessage());
}
return a;
}

//isExist admin uername
public boolean isExistAdmin(String username) throws Exception
{
boolean a=false;
String sql="select * from admin where username='"+username+"';";
rs=dbconnect.executeQuery(sql);
if(rs.next())
{
a=true;
}
rs.close();
return a;
}

///del admin
public void DelAdmin(String username) throws Exception
{
try
{
sql="delete from admin where username='"+username+"';";
dbconnect.executeUpdate(sql);
}
catch(Exception ex)
{
System.out.print("DelAdmin Error:"+ex.getMessage());
}
}

public int getAdminCount(String strsql) //计算查询结果的行数
{
int i=0;
try
{
rs=dbconnect.executeQuery(strsql);
while(rs.next())
{
i=rs.getInt(1);
}
}
catch(Exception ex)
{
System.out.print("AdminControl's getAdminInfo error:"+ex.getMessage());
}
return i;
}

public ArrayList getAdminInfo(String strsql) //得到查询结果
{
ArrayList a=new ArrayList();
try
{
rs=dbconnect.executeQuery(strsql);
while(rs.next())
{
Admin admin=new Admin();
admin.setManage(new String(rs.getString("manage").getBytes("iso-8859-1")));
admin.setUserName(new String(rs.getString("username").getBytes("iso-8859-1")));
admin.setPassword(new String(rs.getString("password").getBytes("iso-8859-1")));
a.add(admin);
}
}
catch(Exception ex)
{
System.out.print("AdminControl's getAdminInfo error:"+ex.getMessage());
}
return a;
}


//UpdateAdmin
public void UpdateAdmin(Admin admin) throws Exception
{
try
{
sql="update admin set password='"+admin.getPassword()+"' manage='"+admin.getManage()+"' where username='"+admin.getUserName()+"';";
dbconnect.executeUpdate(sql);
}
catch(Exception ex)
{
System.out.print("UpdateAdmin Error:"+ex.getMessage());
}
}

public PageBean listData(int page,SearchAdmin searchadmin) throws Exception //获得指定页面的数据,并且封装在PageBean中返回
{
try
{
int count=getAdminCount(searchadmin.strSQL1);
ArrayList result=getAdminInfo(searchadmin.strSQL);
PageBean pagebean=new PageBean(count,result);
ArrayList v=new ArrayList();
int x=(pagebean.maxRowCount<page*pagebean.rowsPerPage?pagebean.maxRowCount:page*pagebean.rowsPerPage);
for(int i=pagebean.rowsPerPage*(page-1);i<x;i++)
{
v.add(result.get(i));
}
pagebean.curPage=page;
pagebean.data=v;
return pagebean;
}
catch(Exception ex)
{
ex.printStackTrace();
throw ex;
}
}


public void close()
{
dbconnect.close();
}

}
neptune0229 2006-10-11
  • 打赏
  • 举报
回复
把AdminControl.java贴上来
qingyun9833 2006-10-11
  • 打赏
  • 举报
回复
/**
* UpdatePWD.java
* author:liuhaijing
* @version 1.0
*/

package mydesign;//包名

import java.io.*;
import mydesign.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class UpdatePWD extends HttpServlet
{

//Initialize global variables
public void init() throws ServletException
{
}

//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
HttpSession session=request.getSession(true);
request.setCharacterEncoding("gb2312");
response.setContentType("text/html; charset=gb2312");
PrintWriter out = response.getWriter();

String username=(String)session.getAttribute("admin");
Admin admin=new Admin();
AdminControl admincontrol=new AdminControl();

String password=request.getParameter("password");//原密码
String password1=request.getParameter("password1");//新密码
String password2=request.getParameter("password2");//确认新密码

//处理数据
try
{
admin.setUserName(username);
admin.setPassword(password);
if(admincontrol.isAdmin(admin)) //检查原密码是否正确
{
if(password1.equals(password2)) //检查两次输入密码是否一致
{
admin.setPassword(password1);
admincontrol.UpdateAdmin(admin);
admincontrol.close();
out.print("<script>alert('成功修改!');window.location.href='updatepwd.jsp'</script>");
}else out.print("<script>alert('两次输入不一致!');history.back()</script>");
}else out.print("<script>alert('密码输入不正确!');history.back()</script>");
}
catch(Exception e)
{
System.out.print("UpdateAdminServlet error:"+e.getMessage());
}
finally
{
}
}

//Clean up resources
public void destroy()
{
}
}
qingyun9833 2006-10-11
  • 打赏
  • 举报
回复
<%@ page contentType="text/html; charset=gb2312" language="java" %>
<%
if(session.getAttribute("admin")==null)
out.print("<script>alert('请先登录!');window.location.href='login.htm'</script>");
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改管理员密码</title>
<link href="css/mycss.css" rel="stylesheet" type="text/css">
<SCRIPT Language="JavaScript">
<!--
//下面的副程序将执行资料检查
function datacheck()
{
//下面的if判断语句将检查是否输入帐号资料
if(form.password.value=="")
{
//显示错误信息
alert("请输入原密码!");
//将光标移至原密码输入栏
document.form.elements(0).focus();
}else{
if(form.password1.value=="")
{
alert("请输入新密码!");
document.form.elements(1).focus();
}else{
if(form.password2.value=="")
{
alert("请输入确认密码!");
document.form.elements(2).focus();
}else{
form.submit();//送出表单中的资料
}
}
}
}
-->
</script>
</head>

<body>
<%@ include file="head.htm" %>
<p> </p>
<p> </p>
<p> </p>

<form action="/MyDesign/UpdatePWD" method="post" name="form" id="form">
<table width="27%" border="1" align="center" cellspacing="0" bordercolor="#660000" bgcolor="#CCCCCC">
<tr>
<td height="62" colspan="2"> <div align="center">
<p><font color="#660000"><strong><font size="5">修改管理员密码</font><font size="5"></font></strong></font></p>
</div></td>
</tr>
<tr>
<td width="40%" height="20"><div align="center"><font color="#660000">原密码<font color="#990000">*</font><strong>
</strong></font></div></td>
<td width="60%"><font color="#660000"><strong>
<input name="password" type="password" id="password" size="10" maxlength="6">
</strong></font></td>
</tr>
<tr>
<td><div align="center"><font color="#660000">新密码<font color="#990000">*</font></font></div></td>
<td><font color="#660000"><strong>
<input name="password1" type="password" id="password1" size="10" maxlength="6">
</strong></font></td>
</tr>
<tr>
<td><div align="center"><font color="#660000">确认新密码<font color="#990000">*</font></font></div></td>
<td><font color="#660000"><strong>
<input name="password2" type="password" id="password2" size="10" maxlength="6">
</strong></font></td>
</tr>
<tr>
<td colspan="2"><div align="center"><font color="#660000"><strong>
<input type="button" name="Submit" value="修改" onclick="datacheck()">
  
<input type="reset" name="Submit2" value="重置">
</strong></font></div></td>
</tr>
</table>
</form>
</body>
</html>
kong_d_f 2006-10-11
  • 打赏
  • 举报
回复
代码放上来看看
qingyun9833 2006-10-11
  • 打赏
  • 举报
回复
我是新手,请各位帮忙看看,在线等!!!
qingyun9833 2006-10-11
  • 打赏
  • 举报
回复
谢谢了 是这里错拉!非常感谢

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧