有没有在不刷新页面的情况下,列表框内容自动更新的方法呢!
解决方案 »
- 求import的详细用法
- 如何用java实现excel转换成csv
- socket编程问题,请高手帮忙
- Netbeans里面的JFrame怎么设置紧张改变大小
- 请教大家:使用Struts,求论坛标题列表生成的解决方案,没有思路了,感谢大家
- 哪有这么干的。 jdom居然不向下兼容。
- 关于加 wav声音的个小问题哦(在线急求 )
- 如何让我的数据库能被银行更新(加急)
- 怎么让打印机自动换行?如果输入的文本很长,没有换行,打印时能否自动换行打印完整
- Could not get JDBC Connection; nested exception is java.sql.SQLException: interr
- long型与字符串之间的转化问题
- 字符比较的问题!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
//设一个变量
var XMLHttpReq=false;
//创建一个XMLHttpRequest对象
function createXMLHttpRequest()
{
if(window.XMLHttpRequest)
{ //Mozilla
XMLHttpReq=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
try
{
XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
}
}
}
}
//发送请求函数
function send(url)
{
createXMLHttpRequest();
XMLHttpReq.open("GET",url,true);
XMLHttpReq.onreadystatechange=proce; //指定响应的函数
XMLHttpReq.send(null); //发送请求
}
function proce()
{
if(XMLHttpReq.readyState==4)
{ //对象状态
if(XMLHttpReq.status==200){//信息已成功返回,开始处理信息
var res=XMLHttpReq.responseXML.getElementsByTagName("content")[0].firstChild.data;
//window.alert(res);
content.innerHTML=res;
}
else
{
window.alert("所请求的页面有异常");
}
}
}
//身份验证
function check()
{
var name=document.getElementById("name").value;
if(name=="")
{
alert("请输入姓名");
return false;
}
else
{
send('login?name='+name);
}
}
</script>
</head>
<body>
<table>
<form name="form" action="login" method="post">
<tr>
<td>
姓名: <input id="name" type="text" name="name" onblur="check();"/>
</td>
<td>
<div id="content"></div>
</td>
</tr>
<tr>
<td>
密码: <input id="pwd" type="password" name="pwd"/>
</td>
</tr>
<tr>
<td>
<input type="button" value="确定>
</td>
</tr>
</form>
</table>
</body>
</html>
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class TestA extends HttpServlet {
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
private String sql;
int i=0;
public TestA () throws Exception
{
con=jdbc.sql();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//设置接收的信息的字符集
request.setCharacterEncoding("UTF-8");
String name=request.getParameter("name");
//设置输出的信息的格式及字符集
response.setContentType("text/xml; charset=UTF-8");
response.setHeader("Cache-Control","no-cache");
//创建输出流
PrintWriter out=response.getWriter();
try
{
stmt=con.createStatement();
sql="select count(*) from admin where name='" + name + "'";
rs=stmt.executeQuery(sql);
while(rs.next())
{
i=rs.getInt(1);
}
}
catch(SQLException e)
{
e.printStackTrace();
}
out.println("<pront>");
if(i>0){
out.println("<content>"+"对不起,此网名已注册!"+"</content>");
}else{
out.println("<content>"+"此网名可以注册!"+"</content>");
}
out.println("</pront>");
out.close();
}
}