帮帮忙吧,第一次写,而且要按时交 type Exception reportmessage 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:358) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) root cause java.lang.NullPointerException org.apache.jsp.login_jsp._jspService(login_jsp.java:64) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
to 楼主: 你调用javabean使用了这一行: <jsp:useBean id="db" class="dbbean.DBConnectionBean" scope="page" /> 你能解释一下里面的参数是什么含义吗?
To 楼主:我确实觉得最好是你自己能多多调试才是,因为我们大家可能能帮你看出点什么,但毕竟我们不可能把从JSP到数据库整个环境搭起来帮你做这个工作,只能凭经验、凭直觉。而且不是谁都那么有时间慢慢帮你看代码。另外,我窃以为你的代码风格并非我所能认同。"能帮人,自己从中又有所收获,何乐而不为":在楼主的这些代码看,不觉得,我肯定会用我自己的也许更好的思路来实现这些,在别人的不太成熟的甚至是没有调试成功的代码上工作,看了半天,也回复了但是得不到重视,除了把自己搞晕,还会有什么收获呢?我是很想帮你,但是我觉得也许你除了发牢骚,应该再做得更多些,我怀疑你有没有好好地看我回复中提到的那些细节,有没有真正仔细认真的分析总结自己的代码可能的问题所在。To 楼上:也许是我脑子短路了,也许是我疏忽,也许是我确实看楼主的代码看得实在有点晕,或者也许是我菜,我也想知道为什么说上面的语句和楼主的错误有关,有什么关系。楼主调用bean的那一句无非是定义一个在page这个scope内有效(当前页面有效,这也是默认的设置),dbbean.DBConnectionBean这个类的实例,把它的引用赋值给名叫db的dbbean.DBConnectionBean类型的变量嘛。这个错了吗?是因为这个所以导致了楼主上面提到的错误信息?能说得再详细点吗?谢谢啦。我实在不想再晕下去了。
首先多谢大胃哥先,thks 我有别的事做,没能来得及跟踪贴子 你们提出来的解法我都试了, 先把 String user= new String(); String psw= new String(); user = request.getParameter("username"); psw = request.getParameter("password"); 改成了 String user = request.getParameter("username"); String psw = request.getParameter("password"); 再有就是增加了user和psw的判断语句 if(user==null || psw ==null){ response.sendRedirect("error.jsp"); }可问题还是老样子!! <jsp:useBean id="db" class="dbbean.DBConnectionBean" scope="page" />这句的意思是 在page 生存空间里声明dbbean.DBConnectionBean db = new dbbean.DBConnectionBean (); bean放置的路径我想是没错的.rs.wasNull()我的理解是判断结果集是否为空,我为了这个函数看了sun 的帮助和到QQ群里问了别人,不过sun的帮助如下 Reports whether the last column read had a value of SQL NULL. Note that you must first call one of the getter methods on a column to try to read its value and then call the method wasNull to see if the value read was SQL NULL. Returns: true if the last column value read was SQL NULL and false otherwise Throws: SQLException - if a database access error occurs 我E文不好看了更糊涂,它提到的是the last column value 是什么意思??是最后一列的值吗??跟我想像的结果差的太远了.我也在想问题是不是出在rs.wasNull里!! 在QQ里也得不到帮助. 这两天我都在找资料,不过资料少得可怜且很多都要收费!! :( 如果大家有什么好资料请发到 [email protected] 谢谢了. 程序结构混乱也是无奈之举,我刚接触jsp的,asp没学过.一切都按我想当然的结构进行了.你们的回复我都有认真看的,还希望高手们跟踪回复,多提出自己的见解和解法~~ 再次感谢大胃哥,我会在线等待....
to 小荷才露尖尖角 你说的work\Standalone\localhost 不存在Standalone文件夹,你的意思是叫我看jsp编绎后的serlet程序么?? jsp 都搞不是很清,serlet更不用说了,痛苦..
type Exception reportmessage 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:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause java.lang.NullPointerException
org.apache.jsp.login_jsp._jspService(login_jsp.java:64)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
你帮我看看一看吧,javaBean在一个示例里用过了,我照班过来的应该没问题.
<%@ page language="java" isThreadSafe="true" %>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>用户登录</title>
</head>
<body bgcolor="#FFCC99">
<embed width="100" height="80" src="flash/DG_globe.swf">
<center><font size=+3>用户信息管理登录</font></center>
<form method="post" action="login.jsp">
<center>用户名:<input type="text" name="username" maxlength=20></center>
<p>
<p>
<p>
<center>密 码:<input type="password" name="password" maxlength=20></center>
<p>
<p>
<p>
<center><input type="submit" name="login" value="登录">
<input type="reset" name="cancel" value="取消">
</center>
</form>
<p>
<p>
<p>
<p>
<center>如果你还不是本站用户,请在此<a href="register.jsp">注册</a><center></body>
</html>
String user= new String();
String psw= new String();
user = request.getParameter("username");
psw = request.getParameter("password");
改成:
String user = request.getParameter("username");
String psw = request.getParameter("password");
然后在后面的if语句中加入对user和psw是否为null的判断。
能帮人,自己从中又有所收获,何乐而不为
help~~
我一行一行地也不知看了多少遍也找不到问题所!!
eclipse提示 "为不能解析 dbbean,或者它不是一种类型"
期待高手回复
String user= new String();
String psw= new String();
user = request.getParameter("username");
psw = request.getParameter("password");
改成:
String user = request.getParameter("username");
String psw = request.getParameter("password");
?????
有什么区别吗?
你调用javabean使用了这一行:
<jsp:useBean id="db" class="dbbean.DBConnectionBean" scope="page" />
你能解释一下里面的参数是什么含义吗?
找到工作目录(tomcat下为work\Standalone\localhost)
找到相应类文件(应该有个register字段)
仔细看看那个类文件?sean_gao(大胃)似乎很积极啊,俺才看的几个帖子里都有你的详细报道。
你是专业人士么,如果不是,似乎你花的时间有点...,呵呵
我有别的事做,没能来得及跟踪贴子
你们提出来的解法我都试了,
先把
String user= new String();
String psw= new String();
user = request.getParameter("username");
psw = request.getParameter("password");
改成了
String user = request.getParameter("username");
String psw = request.getParameter("password");
再有就是增加了user和psw的判断语句
if(user==null || psw ==null){
response.sendRedirect("error.jsp");
}可问题还是老样子!!
<jsp:useBean id="db" class="dbbean.DBConnectionBean" scope="page" />这句的意思是
在page 生存空间里声明dbbean.DBConnectionBean db = new dbbean.DBConnectionBean ();
bean放置的路径我想是没错的.rs.wasNull()我的理解是判断结果集是否为空,我为了这个函数看了sun 的帮助和到QQ群里问了别人,不过sun的帮助如下
Reports whether the last column read had a value of SQL NULL. Note that you must first call one of the getter methods on a column to try to read its value and then call the method wasNull to see if the value read was SQL NULL. Returns:
true if the last column value read was SQL NULL and false otherwise
Throws:
SQLException - if a database access error occurs
我E文不好看了更糊涂,它提到的是the last column value 是什么意思??是最后一列的值吗??跟我想像的结果差的太远了.我也在想问题是不是出在rs.wasNull里!!
在QQ里也得不到帮助.
这两天我都在找资料,不过资料少得可怜且很多都要收费!! :(
如果大家有什么好资料请发到 [email protected] 谢谢了.
程序结构混乱也是无奈之举,我刚接触jsp的,asp没学过.一切都按我想当然的结构进行了.你们的回复我都有认真看的,还希望高手们跟踪回复,多提出自己的见解和解法~~
再次感谢大胃哥,我会在线等待....
你说的work\Standalone\localhost
不存在Standalone文件夹,你的意思是叫我看jsp编绎后的serlet程序么??
jsp 都搞不是很清,serlet更不用说了,痛苦..
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;public final class login_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent { private static java.util.Vector _jspx_dependants; public java.util.List getDependants() {
return _jspx_dependants;
} public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException { JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out; out.write("\r\n");
out.write("\r\n");
dbbean.DBConnectionBean db = null;
synchronized (_jspx_page_context) {
db = (dbbean.DBConnectionBean) _jspx_page_context.getAttribute("db", PageContext.PAGE_SCOPE);
if (db == null){
db = new dbbean.DBConnectionBean();
_jspx_page_context.setAttribute("db", db, PageContext.PAGE_SCOPE);
}
}
out.write("\r\n");
out.write("<!DOCTYPE HTML PUBLIC \"-//w3c//dtd html 4.0 transitional//en\">\r\n");
out.write("\r\n"); String user = request.getParameter("username");
String psw = request.getParameter("pass");
if(user.length()*psw.length()==0){
response.sendRedirect("error.jsp");
}
if(user.equals("Admin")){//脜脨露脧脢脟路帽脦陋鹿脺脌铆脭卤
ResultSet rs = db.executeQuery("select * from 脫脙禄搂禄霉卤戮脨脜脧垄 where 脫脙禄搂脮脢潞脜='"+ user
+"' "+"and 脫脙禄搂脙脺脗毛='" + psw+"'");
// di 64 heng di 64 heng~~~~~~~~~~~~~~~~~~~~~
if(!rs.wasNull){
session.setAttribute("username",user);
session.setAttribute("password", psw);
response.sendRedirect("manage.jsp");
}else{
response.sendRedirect("error.jsp");}
}else{
//脜脨露脧脢脟路帽脦陋脪禄掳茫脫脙禄搂
ResultSet rs = db.executeQuery("select * from 脫脙禄搂禄霉卤戮脨脜脧垄 where 脫脙禄搂脮脢潞脜='"+user
+"' "+"and 脫脙禄搂脙脺脗毛='" + psw+"'");
if(!rs.wasNull){
session.setAttribute("username",user);
session.setAttribute("password", psw);
response.sendRedirect("user.jsp");
}
//录脠虏禄脢脟鹿脺脌铆脭卤脪虏虏禄脢脟脪禄掳茫脫脙禄搂
else{response.sendRedirect("error.jsp");}
} out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
ResultSet rs = db.executeQuery("select * from 脫脙禄搂禄霉卤戮脨脜脧垄 where 脫脙禄搂脮脢潞脜='"+ user
+"' "+"and 脫脙禄搂脙脺脗毛='" + psw+"'");
ResultSet rs = db.executeQuery("select * form 用户基本信息 where 用户帐号='"+user
+"' "+"and 用户密码='" + psw+"'");
ResultSet res = stmt.executeQuery(...);
...
return res;
应该用while(rs.next())
而不是用rs.wasNull()
建议楼主先把数据库字段名改成英文
while(rs.next())之前我试过了,也不成是不是支持不了中文的字段??
我猜搂主的数据库中是不是把用户帐号定义为了其他什么类型。而不是字符串。
如果是,在从数据库中读时应有个类型转换。
结构应该清析多了,希望大家能看完
<%@ page language="java" %>
<%@ page import="java.sql.*"%>
<%--jsp:useBean id="db" class="dbbean.DBConnectionBean" scope="page" --%>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en"><%
String constr="jdbc:odbc:userinfo";
String _user="";
String _password=""; String user = (String)request.getParameter("username");
String psw = (String)request.getParameter("pass");
if(user.length()*psw.length()==0){
response.sendRedirect("error.jsp");
}
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection(constr,_user,_password);
Statement s=c.createStatement();
ResultSet rs = s.executeQuery("select 用户帐号,用户密码 from 用户基本信息");
while(rs.next()){
if(user.equals(rs.getString("用户帐号"))&& psw.equals(rs.getString("用户密码"))){
if(user.equals("Admin")) {response.sendRedirect("manage.jsp");}
response.sendRedirect("user.jsp");
}
}
// rs.close();
}catch(SQLException e){e.printStackTrace();}
catch(ClassNotFoundException e){e.printStackTrace();}
%>编绎是正确的,但就是不能取得数据库里的数据!
我的程序错在那了?或者说可能错在那了????
ResultSet rs = s.executeQuery("select 用户帐号,用户密码 from 用户基本信息");这句执行时不异常!!
不过我也不明白为什么会有异常,
我试过新建了一个表,字段是E文的都不成.
为什么呢???谁能告诉我!!!!
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT ?????
然后一步步来,简化问题晕,像你这么学,不如从头开始仅仅是肺腑之言,楼主不要K俺
原来是jsp不支持中文
加多这一句就可以了<%@ page contentType="text/html;charset=gb2312" %>
欲哭无泪,想跳楼,真的再次多谢大胃哥和小荷才露尖尖角
问题还存在!
大家继续发言为什么使用javabean就不成??!why????
大家可以说说可能出错在那个地方
<%@ page import="java.sql.*"%>
<%@ page contentType="text/html;charset=gb2312" %><jsp:useBean id="db" class="dbbean.DBConnectionBean" scope="page"/>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html><title>afda</title>
<body><%
String user = request.getParameter("username");
String psw = request.getParameter("pass");
if(user.length()*psw.length()==0){
response.sendRedirect("error.jsp");
}
out.print("错了吗4?");
String sql = "select * from 用户基本信息";
ResultSet rs = db.executeQuery(sql);
out.print("错了吗5?");
while(rs.next()){
if(user.equals(rs.getString("用户帐号"))&& psw.equals(rs.getString("用户密码"))){
if(user.equals("Admin")) {out.print("错了吗6?");}//response.sendRedirect("manage.jsp");}
else out.print("错了吗7?");//response.sendRedirect("user.jsp");
}
} //rs.close();s.close();
out.print("错了吗8?");
%></body>
</html>
javabean也可以是这样
现在的javaBean我在编绎时加上了 -encoding ISO8859-1 都不成,
就中文问题我试了编码转换等都不成,不知为什么
大家继续帮我提意见吧