我把错误提示和源代码发布出来,请指教~~~~~~~~~~``
我把错误提示和源代码发布出来
希望哪位大虾指教一下~~~~~~~~~~~~~~~~
我在jsp文件里面调用一个student.java生成的类
出现下面的错误提示:
/updatestudent.jsp:7: cannot resolve symbol
symbol : class student
location: class _jsp._updatestudent__jsp
student update;
^
/updatestudent.jsp:8: cannot resolve symbol
symbol : class student
location: class _jsp._updatestudent__jsp
update = (student) pageContext.getAttribute("update");
-------------------------------------------------------------------
源代码:
addstudent.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<jsp:useBean id="update" scope="page" class="student">
<jsp:setProperty name="update" property="*"/>
</jsp:useBean>
<body bgcolor="#0099FF" text="#FFFFFF" link="#00FF00">
<%
try {
String s = request.getParameter("password");
if(s==null || s.equals("")) throw new Exception("错误,密码不能为空!!");
String stu_id = (String)session.getAttribute("id");
if(stu_id==null){response.sendRedirect("login.jsp");}
update.setStu_id(stu_id);
update.update();
String d= update.getStu_id();
out.print("学生号: "+d+"<br>");
String a = update.getPassword();
out.print("您的新密码: "+a+"<br>");
String b= update.getTel();
out.print("您的电话: "+b+"<br>");
String c= update.getE_mail();
out.print("E_mail: "+c+"<br>");
%>
<p><a href="student.jsp"><<您已经更新成功,请返回</a>
<p>
<%
}catch (Exception e){out.print(e.toString());}
%>
</body>
</html>
----------------------------------------------------------------
student.java
import java.sql.*;
package student;
public class student {
private String name;
private String password;
private String id;
private String jiguan;
private String sex;
private String dep;
public void setDep(String s){dep=s;}
public String getDep(){return dep;}
public void setSex(String s){sex=s;}
public String getSex(){return sex;}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getJiguan() {
return jiguan;
}
public void setJiguan(String jiguan) {
this.jiguan = jiguan;
}
public boolean hasLogin(String id){ //检查该学生是否已经注册
boolean f=true;
String sql="select id from student where id ='"+id+"'";
sqlBean db =new sqlBean();
try{
ResultSet rs=db.executeQuery(sql);
if(rs.next()){ f=false;}
else{ f=true;}
}catch(Exception e){ e.getMessage();}
return f;
}
public ResultSet getStudent(){
String sql="select * from student ";
sqlBean db= new sqlBean();
ResultSet rs = db.executeQuery(sql);
return rs;
}
public void updateStudent(){
String sql="update student "+
" set name='"+name+"',sex='"+sex+"',department='"+dep+"', "+
"password='"+password+"',jiguan='"+jiguan+"' "+
" where id='"+id+"' ";
sqlBean db= new sqlBean();
db.executeInsert(sql);
}
public void deleteStudent(){
String sql="delete from student where id ='"+id+"' ";
sqlBean db= new sqlBean();
db.executeDelete(sql);
}
public int deleteStudent(String id){
int num=0;
String sql="delete from student where id ='"+id+"' ";
sqlBean db= new sqlBean();
num=db.executeDelete(sql);
return num;
}
public void addStudent() {
String sql="insert into student(name,password,id,sex,department,jiguan) "+
"VALUES('"+name+"','"+password+"','"+id+"','"+sex+"','"+dep+"','"+jiguan+"')";
sqlBean db =new sqlBean();
db.executeInsert(sql);
}
}
-------------------------------------------------------------
请指教~~~~~~~~~~~~急急急~~~~~~~~~~:(
问题点数:0、回复次数:3Top
1 楼hewei2003(为为)回复于 2004-05-02 22:53:21 得分 0
student.class文件放在什么位置的?Top
2 楼fuzuyuan(happyboy)回复于 2004-05-03 00:00:45 得分 0
<jsp:useBean id="update" scope="page" class="student">
<jsp:setProperty name="update" property="*"/>
</jsp:useBean>
改为
<jsp:useBean id="update" scope="page" class="student.student">
<jsp:setProperty name="update" property="*"/>
</jsp:useBean>
student应该在classes\student目录下Top
3 楼alan520cf(alan)回复于 2004-05-03 00:32:49 得分 0
student原来放在WEB-INF\classes下
StudentLoginSvlt.class放在WEB-INF\classes下
student.jsp文件中调用StudentLoginSvlt.class
错误提示如下:
com.caucho.java.JavaCompileException: /checkmark.jsp:3: cannot resolve symbol symbol : class checkEnrol
location: class _jsp._checkmark__jsp checkEnrol check; ^
/checkmark.jsp:4: cannot resolve symbol symbol : class checkEnrol location: class _jsp._checkmark__jsp check = (checkEnrol) pageContext.getAttribute("check"); ^ /checkmark.jsp:6: cannot resolve symbol symbol : class checkEnrol location: class _jsp._checkmark__jsp check = new checkEnrol(); ^ 3 errors
-------------------------------------------------------------
student.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="errorpage.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#0099FF" text="#00FF00" link="#CCFF00">
<p>
<%
String id = (String)session.getAttribute("id");
//if(stu_id==null){response.sendRedirect("login.jsp");}
%>
<font size="+2" face="华文行楷">您已经成功通过验证! 您可以使用如下服务:</font> </p>
<p> </p>
<p> </p>
<table width="58%" border="0" align="center">
<tr>
<td><a href="DisplayCourse.jsp">选修课程</a></td>
------------------------------------------------------------------------------
问题就是下面一句:
-----------------------------------------------------------------------------
<td><a href="StudentLoginSvlt?id=<%=id%>&action=checkmark">察看学分</a></td>
------------------------------------------------------------------------------
~~请指教
------------------------------------------------------------------------------
<td><a href="updateinformation.jsp">更改信息</a></td>
</tr>
</table>
<p> </p><p> </p><p><a href="login_confirm?action=logout"><<注销 </a></p>
</body>
</html>
------------------------------------------------------------------------------
checkmark.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="errorpage.jsp" %>
<html>
<jsp:useBean id="check" scope="page" class="checkEnrol">
<body bgcolor="#0099FF" text="#FFFFFF">
<p align="center"><font color="#00FF00" size="+3" face="华文行楷">学生成绩</font></p>
<p> </p>
<table width="463" border="1" align="center">
<tr>
<td width="207" height="34">课程</td>
<td width="85">学分</td><td width="149">成绩</td></tr>
<%
String stu_id = (String)session.getAttribute("id");
if(stu_id==null){response.sendRedirect("login.jsp");}
String score,name;
int mark=0;
ResultSet rs =(ResultSet) request.getAttribute("rs");
while(rs.next()) {
score=rs.getString("score");
name=rs.getString("name");
mark=rs.getInt("mark");
if(score.equals("0") )
score="成绩未给出";
%>
<tr>
<td height="34"><%=name%></td><td><%=mark%></td><td><%=score%></td></tr>
<%
}
%>
</table>
<%
String temp=check.getTotalMark(stu_id);
%>
您的总得分为:<%=temp%>
<p><a href="student.jsp"><<<strong>Back</strong></a></p>
</body>
</html>
----------------------------------------------------------------------------
StudentLoginSvlt.java
import java.io.*;
import java.sql.ResultSet;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class StudentLoginSvlt extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String stu_id =req.getParameter("id");
String cour_id=req.getParameter("cour_id");
String class_id=req.getParameter("class_id");
String prepare=req.getParameter("prepare");
String pw1=null;
String pw2=null;
String e_mail=null;
String tel=null;
String action = req.getParameter("action");
ResultSet rs=null;
if ("update".equalsIgnoreCase(action)) {
stu_id =req.getParameter("id");
pw1=req.getParameter("password1");
pw2=req.getParameter("password2");
if(pw1.equals("") || pw2.equals("") || pw1==null || pw2==null)
doError(req,res,"密码不能为空!");
e_mail=req.getParameter("e_mail");
tel=req.getParameter("tel");
doUpdate(req,res,pw1,pw2,e_mail,tel,stu_id);
res.sendRedirect("/test/student.jsp");
}
if ("checkmark".equalsIgnoreCase(action)) {
rs=getScore(stu_id) ;
sendResultSet(req,res,rs,"/checkmark.jsp");
}
if("enrol".equalsIgnoreCase(action)){
doEnrol(req,res,stu_id,cour_id,class_id,prepare);
res.sendRedirect("/test/DisplayCourse.jsp");}
}
public void doEnrol(HttpServletRequest req, HttpServletResponse res,
String stu_id,String cour_id,String class_id,String prepare)
throws ServletException, IOException {
int num=0;
checkEnrol check=new checkEnrol();
if(prepare.equals("0") )
{ num= check.enrol(class_id,stu_id); }
else {
if( check.hasPassPrepare(prepare))
{num= check.enrol(class_id,stu_id);}
else doError(req,res,"清先完成预修课");
}
if(num==0){
doError(req,res,"注册课程失败!!");
}
}
public void doUpdate(HttpServletRequest req, HttpServletResponse res,
String pw1,String pw2,String e_mail,String tel,String id)
throws ServletException, IOException{
int num=0;
if(!pw1.equals(pw2))
doError(req,res,"密码不一致,请重输!");
checkEnrol check=new checkEnrol();
sqlBean db = new sqlBean();
num= check.updatestu(pw1,id,e_mail,tel);
if(num==0) doError(req,res,"更新失败");
}
public ResultSet getScore(String stu_id){
String sql="select enrol.score , course.name ,course.mark "+
"from enrol ,course ,classes "+
"where stu_id='"+stu_id+"' "+
"and enrol.class_id=classes.id "+
"and classes.cour_id=course.id ";
sqlBean db = new sqlBean();
ResultSet rs= db.executeQuery(sql);
return rs;
}
public void doError(HttpServletRequest req,
HttpServletResponse res,
String str)
throws ServletException, IOException {
req.setAttribute("problem", str);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/errorpage.jsp");
rd.forward(req, res);
}
public void sendResultSet(HttpServletRequest req, HttpServletResponse res,
java.sql.ResultSet rs, String target)
throws ServletException, IOException {
req.setAttribute("rs", rs);
RequestDispatcher rd = getServletContext().getRequestDispatcher(target);
rd.forward(req, res);
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doGet(req, res);
}
}
Top




