小弟求救JSP+Javabean注册登陆问题

laoyao319 2006-03-18 09:33:18
<%@page contentType="text/html; charset=GBK"%>
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@page import="wo.UntitledDao"%>
<%String str = response.encodeRedirectURL("adduser.jsp");%>
<form action="<%=str%>" method="POST">
<br/>
注册名
<input type="text" name="name"/>
<br/>
密码
<input type="text" name="password"/>
<input type="text" name="type"/>
<input type="submit" value="tij" name="g"/>
</form>
<jsp:useBean id="bean" scope="request" class="wo.UntitledDao"/>
<%
String name = "", pass = "", type = "";
name = request.getParameter("name");
pass = request.getParameter("password");
type = request.getParameter("type");%>
<jsp:setProperty name="bean" property="*"/>
<% try {
String s="'"+name+"'"+","+"'"+pass+"'"+","+"'"+type+"'";
String sqll="insert into table2 values"+"("+s+")";
bean.executeupdate(sqll);
ResultSet rs = bean.executeQuery("select * from table2");
while (rs.next())
out.println(rs.getString(2) + "<br/>");
rs.close();
bean.closedb();
}
catch (SQLException sex) {
sex.printStackTrace();
}
%>

package wo;
import java.sql.*;
public class UntitledDao {
Connection con = null;
ResultSet rs = null;
String name="",pass="",type="";
public UntitledDao() {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public void setln(String name){name=name;}
public String getln(){return name;}

public void setpw(String pw){pass=pw;}
public String getpassword(){return pass;}
public void settp(String tp){type=tp;}
public String gettp(){return type;}

public ResultSet executeQuery(String sql) {
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=aa";
String user = "sa";
String password = "123456";
try {
con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
} catch (SQLException f) {
f.printStackTrace();
}
return rs;
}
public void executeupdate(String sqll) {
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=aa";
String user = "sa";
String password = "123456";
try {
con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
stmt.executeUpdate(sqll);
} catch (SQLException f) {
f.printStackTrace();
}

}


public void closedb() {
try {
rs.close();
con.close();
} catch (SQLException g) {
g.printStackTrace();
}
}
运行出现URL: Unable to open location: Document not found on server,可是我把.CLASS文件已经放在D:\jakarta-tomcat-5.0.28\jakarta-tomcat-5.0.28\classes了?
...全文
91 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
wxl565 2006-03-18
.class 文件是要放在你的TOMCAT目录里的webapp\你的web文件夹\WEB-INF\CLASS文件夹下的
回复
zx2002027 2006-03-18
放在D:\jakarta-tomcat-5.0.28\jakarta-tomcat-5.0.28\yourwebapp\WEB-INF\classes\wo下面
另外确认classpath配置无问题
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2006-03-18 09:33
社区公告
暂无公告