<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
color: #333333;
}
body {
background-color: #FFFF99;
}
-->
</style>
<%
String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\Tomcat4\\webapps\\ROOT\\web1\\web\\db1.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(url);
Statement st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql="select name from user where name=name";
st.executeQuery(sql);if(st.next())
out.print("<center>用户名和密码不匹配");
else
%>
<script language="javascript">
function on_submit()
{
if (form1.name.value=="")
{
alert("用户名不能为空,请输入用户名!")
form1.name.focus();
return false;
}<script language="javascript">
function on_submit()
{
if (form1.name.value=="")
{
alert("用户名不能为空,请输入用户名!")
form1.name.focus();
return false;
}
if (form1.userpassword.value=="")
{
alert("密码不能为空,请输入密码!")
form1.userpassword.focus();
return false;
}
if (form1.reuserpassword.value=="")
{
alert("确认密码不能为空,请输入密码!")
form1.reuserpassword.focus();
return false;
}
if (form1.userpassword.value!=form1.reuserpassword.value)
{
alert("密码与确认密码不相同")
form1.reuserpassword.focus();
return false;
}}
</script>
</head><body>
<form name="form1" method="post" action="userregist.jsp" onsubmit="return on_submit()">
<table width="734" height="247" border="0">
<tr>
<td width="127" height="243"> </td>
<td width="472" valign="top"><table width="472" border="0">
<tr>
<td height="69" colspan="2"> </td>
</tr>
<tr>
<td width="75" height="21" align="center" nowrap="nowrap">用 户 名</td>
<td width="383" height="20" align="left"><input type="text" name="name" /></td>
</tr>
<tr>
<td width="75" height="25" align="center">密 码</td>
<td height="20" align="left">
<input type="password" name="userpassword" ></td>
</tr>
<tr>
<td width="75" height="25" align="center" nowrap="nowrap">密码确认</td>
<td height="20" align="left">
<input type="password" name="reuserpassword" ></td>
</tr>
<tr>
<td width="75" height="22" align="center" valign="middle">部 门</td>
<td height="20" align="left"><select name="partment">
<option>办公室</option>
<option>人教育科</option>
<option>征收管理科</option>
<option>税政科</option>
<option>计征科</option>
<option>信息中心</option>
<option>稽查局</option>
<option>双江分局</option>
</select></td>
</tr>
<tr>
<td width="75" height="20" align="center">职 务</td>
<td align="left"><select name="funtion">
<option>局长 </option>
<option>副局长</option>
<option>科长</option>
<option>副科长</option>
<option>主任</option>
<option>副主任</option>
<option>国税干部 </option>
</select></td>
</tr>
<tr>
<td height="29" align="center"> </td>
<td align="left" valign="top"><table width="80" border="0">
<tr>
<td width="90" height="23" align="center"><input type="submit" name="Submit" value="提交" /></td>
<td width="315"><input type="reset" name="Submit2" value="重置" /></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="121"> </td>
</tr>
</table>
</form>
<% st.close();
con.close();
%>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
color: #333333;
}
body {
background-color: #FFFF99;
}
-->
</style>
<%
String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\Tomcat4\\webapps\\ROOT\\web1\\web\\db1.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(url);
Statement st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql="select name from user where name=name";
st.executeQuery(sql);if(st.next())
out.print("<center>用户名和密码不匹配");
else
%>
<script language="javascript">
function on_submit()
{
if (form1.name.value=="")
{
alert("用户名不能为空,请输入用户名!")
form1.name.focus();
return false;
}<script language="javascript">
function on_submit()
{
if (form1.name.value=="")
{
alert("用户名不能为空,请输入用户名!")
form1.name.focus();
return false;
}
if (form1.userpassword.value=="")
{
alert("密码不能为空,请输入密码!")
form1.userpassword.focus();
return false;
}
if (form1.reuserpassword.value=="")
{
alert("确认密码不能为空,请输入密码!")
form1.reuserpassword.focus();
return false;
}
if (form1.userpassword.value!=form1.reuserpassword.value)
{
alert("密码与确认密码不相同")
form1.reuserpassword.focus();
return false;
}}
</script>
</head><body>
<form name="form1" method="post" action="userregist.jsp" onsubmit="return on_submit()">
<table width="734" height="247" border="0">
<tr>
<td width="127" height="243"> </td>
<td width="472" valign="top"><table width="472" border="0">
<tr>
<td height="69" colspan="2"> </td>
</tr>
<tr>
<td width="75" height="21" align="center" nowrap="nowrap">用 户 名</td>
<td width="383" height="20" align="left"><input type="text" name="name" /></td>
</tr>
<tr>
<td width="75" height="25" align="center">密 码</td>
<td height="20" align="left">
<input type="password" name="userpassword" ></td>
</tr>
<tr>
<td width="75" height="25" align="center" nowrap="nowrap">密码确认</td>
<td height="20" align="left">
<input type="password" name="reuserpassword" ></td>
</tr>
<tr>
<td width="75" height="22" align="center" valign="middle">部 门</td>
<td height="20" align="left"><select name="partment">
<option>办公室</option>
<option>人教育科</option>
<option>征收管理科</option>
<option>税政科</option>
<option>计征科</option>
<option>信息中心</option>
<option>稽查局</option>
<option>双江分局</option>
</select></td>
</tr>
<tr>
<td width="75" height="20" align="center">职 务</td>
<td align="left"><select name="funtion">
<option>局长 </option>
<option>副局长</option>
<option>科长</option>
<option>副科长</option>
<option>主任</option>
<option>副主任</option>
<option>国税干部 </option>
</select></td>
</tr>
<tr>
<td height="29" align="center"> </td>
<td align="left" valign="top"><table width="80" border="0">
<tr>
<td width="90" height="23" align="center"><input type="submit" name="Submit" value="提交" /></td>
<td width="315"><input type="reset" name="Submit2" value="重置" /></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="121"> </td>
</tr>
</table>
</form>
<% st.close();
con.close();
%>
</body>
</html>
错误提示如下:
Generated servlet error:
[javac] Compiling 1 source fileD:\Tomcat4\work\Standalone\localhost\_\web1\web\denglu_jsp.java:64: cannot resolve symbol
symbol : method next ()
location: interface java.sql.Statement
if(st.next())
要想判断是否有记录
必须用Statement 类的返回参数RresultSet 这个类想定义一个对象
ResultSet rs=st.executequery(sql)
然后用rs来判断是否有记录
if(rs.next()){
}
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 16 in the jsp file: /web1/web/denglu.jspGenerated servlet error:
[javac] Compiling 1 source fileD:\Tomcat4\work\Standalone\localhost\_\web1\web\denglu_jsp.java:63: cannot resolve symbol
symbol : method executequery (java.lang.String)
location: interface java.sql.Statement
ResultSet rs=st.executequery(sql);
^
1 error
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:248)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:315)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:328)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
<%String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\Tomcat4\\webapps\\ROOT\\web1\\web\\db1.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(url);
Statement st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql="select name from user where name=name";
ResultSet rs=st.executequery(sql);
st.executeQuery(sql);
if(rs.next())
out.print("<center>用户名和密码不匹配");
else
%>