调用Bean的问题??

bafnay 2004-11-01 05:23:29

<%@ page language="java" errorPage="error.jsp" import="com.jspdev.ch5.*" isErrorPage=true%>

<jsp:useBean id="userInfo" class="com.jspdev.ch5.UserInfo" scope="page">
<jsp:setProperty name="userInfo" property="*"/>
</jsp:useBean>
<jsp:useBean id="regist" class="com.jspdev.ch5.UserRegist" scope="page"/>
<html>
<head>
<title>用户信息注册页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<LINK href="hellking.css" type=text/css rel=stylesheet>
<body>
<%

regist.setUserInfo(userInfo);
regist.regist();
out.println("注册成功");
%>
<br>
<a href="main.jsp">返回</a>
</body>
</html>

错误 如下:
type Exception report

message

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

exception

org.apache.jasper.JasperException: /newuser.jsp(1,87) quote symbol expected
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:90)
org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:198)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:143)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:156)
org.apache.jasper.compiler.ParserController.getPageEncodingForJspSyntax(ParserController.java:452)
org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:386)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:170)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
...全文
129 点赞 收藏 18
写回复
18 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
snoics 2004-11-02
大概是运行的时候遇到有一些变量的值为NULL
回复
dafei0320 2004-11-02
遇到过-关注!
回复
tiannet 2004-11-02
空指针的错误一般都是因为对象的值为null,
然后你使用了对象的某个方法
回复
nortan 2004-11-02
遇到类似问题,up………………
不过在public class UserRegist构造方法中以得到数据连接在JSP不用得到它的对象吗?
回复
bafnay 2004-11-02
我试了不是不行?
回复
tomwen 2004-11-02
狂顶
回复
tomwen 2004-11-01
dingdingdingdingding
我也是这个问题
求高手帮忙
回复
shuzhifeng 2004-11-01
我也有一样的问题!
回复
tomwen 2004-11-01
顶顶顶顶顶
回复
cyicecream 2004-11-01
String reg="insert into user_Info values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
改为
String reg="insert into user_Info (userid,name...加入问号对应的字段)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
回复
bafnay 2004-11-01
我改了还是提错如下:
type Exception report

message

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

exception

org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)


root cause

java.lang.NullPointerException
com.jspdev.ch5.UserRegist.regist(UserRegist.java:41)
org.apache.jsp.newuser_jsp._jspService(newuser_jsp.java:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.jspdev.ch8.EncodingFilter.doFilter(EncodingFilter.java:36)


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

回复
bafnay 2004-11-01
哦,好的,可是我改了还是不行啊
回复
iamkkk 2004-11-01
Page errorPage 指令和 Page isErrorPage = "true"不能在一个jsp里用吧?你在这个jsp里指定了Page errorPage =“error.jsp” 那你的Page isErrorPage = “ture”就应该在error.jsp里面出现 因为你把错误信息转发给了 error.jsp了。
回复
bafnay 2004-11-01
package com.jspdev.ch5;
import com.microsoft.jdbc.sqlserver.SQLServerDriver;
import java.sql.*;

public class UserRegist
{
private UserInfo userInfo;
private Connection con;

//获得数据库连接。
public UserRegist()
{
String CLASSFORNAME="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String SERVANDDB="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev";
String USER="bn";
String PWD="bn";
try
{

Class.forName(CLASSFORNAME);
con = DriverManager.getConnection(SERVANDDB,USER,PWD);
}
catch(Exception e)
{
e.printStackTrace();
}
}
//设置待注册的用户信息。
public void setUserInfo(UserInfo userInfo)
{
this.userInfo=userInfo;
}

//进行注册
public void regist()throws Exception
{
String reg="insert into user_Info values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

try
{
PreparedStatement pstmt=con.prepareStatement(reg);
pstmt.setString(1,userInfo.getUserid());
pstmt.setString(2,userInfo.getName());
pstmt.setString(3,userInfo.getPhone());
pstmt.setString(4,userInfo.getStreet());
pstmt.setString(5,userInfo.getState());
pstmt.setString(7,userInfo.getCity());
pstmt.setString(6,userInfo.getZipCode());
pstmt.setString(8,userInfo.getEmail());
pstmt.setString(9,userInfo.getCardNumber());
pstmt.setInt(10,userInfo.getCardType());
pstmt.setInt(11,0);
pstmt.setDate(12,new java.sql.Date(new java.util.Date().getTime()));
pstmt.setInt(13,1);
pstmt.setInt(14,0);
pstmt.setString(15,userInfo.getFanvcategory());
pstmt.setString(16,userInfo.getPassword());
pstmt.executeUpdate();
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}
}
}




回复
bafnay 2004-11-01
package com.jspdev.ch5;
import java.util.Date;
public class UserInfo
{
//属性
private String userid;
private String password;
private String email;
private String name;
private String street;
private String city;
private String state;
private String phone;
private String zipCode;
private String cardNumber;
private int cardType;
private Date expireDate;
private int userLogCount;
private int userType ;
private Date userLastLogTime;
private String fanvcategory;

//getter方法
public String getUserid()
{
return this.userid;
}
public String getEmail()
{
return this.email;
}
public String getPassword()
{
return this.password;
}
public String getState()
{
return this.state;
}
public String getStreet()
{
return this.street;
}
public String getCity()
{
return this.city;
}
public String getZipCode()
{
return this.zipCode;
}
public String getPhone()
{
return this.phone;
}
public String getCardNumber()
{
return this.cardNumber;
}
public int getCardType()
{
return this.cardType;
}
public Date getExpireDate()
{
return this.expireDate;
}
public int getUserType()
{
return this.userType;
}
public String getFanvcategory()
{
return this.fanvcategory;
}
public String getName()
{
return this.name;
}
public int getUserLogCount()
{
return this.userLogCount;
}

//setter方法
public void setUserid(String c)
{
this.userid=c;
}
public void setName(String c)
{
this.name=c;
}

public void setEmail(String c)
{
this.email=c;
}
public void setState(String c)
{
this.state=c;
}
public void setStreet(String c)
{
this.street=c;
}
public void setCity(String c)
{
this.city=c;
}

public void setZipCode(String c)
{
this.zipCode=c;
}
public void setPhone(String c)
{
this.phone=c;
}
public void setFanvcategory(String c)
{
this.fanvcategory=c;
}
public void setUserType(int c)
{
this.userType=c;
}

public void setPassword(String c)
{
this.password=c;
}
public void setCardNumber(String c)
{
this.cardNumber=c;
}
public void setCardType(int c)
{
this.cardType=c;
}

}
回复
victorylj 2004-11-01
吧javaBean发上来
回复
bafnay 2004-11-01
好的我试一下!
回复
tom2005 2004-11-01
isErrorPage=true
改为
isErrorPage="true"
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告