ImageVerifierCode 换一换
格式:DOCX , 页数:11 ,大小:17.35KB ,
资源ID:19693214      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/19693214.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(jsp代码文档格式.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

jsp代码文档格式.docx

1、javascript 创建XMLHttpRequest 对象-var xmlHttp = false;if(window.ActiveXObject)xmlHttp=new ActiveXObject(Microsoft.XMLHTTP);else if(window.XMLHttpRequest)xmlHttp=new XMLHttpRequest(); 发送请求-function checkUser() var userName = document.getElementById (userName).value;var url = CheckUserName?userName= + us

2、erName;xmlHttp.open(GET, url, true);xmlHttp.onreadystatechange = updatePage;xmlHttp.send(null); 返回结果处理- function updatePage() if (xmlHttp.readyState = 4)if(xmlHttp.status=200)var response = xmlHttp.responseText;var result=此帐号可以使用! ;if(response.indexOf(true)! =-1) result=很遗憾,该帐号已经被占用,请您另选一个document.g

3、etElementById(result).innerHTML=result;/script/headbodybrform id=regForm action= table border=0 align=center width=400tbodytrth colspan=2/th/trtr class=zi9pttd bgcolor=right帐号:/tdtd input type = text value = id = name= onblur=checkUser()/td colspan =2 div align = style=12px;color=red提示:用户帐号,不能包含空格、t

4、d align=密码:tdinput type=password value= id=pswd确认密码:repswdtd colspan=2 align=centersubmitvalue= 确&定&/tbody/table/form/body/htmlServlet 类CheckUserName.javapackage ;import java.io.IOException;import java.io.PrintWriter;import java.sql.DriverManager;import java.sql.SQLException;import javax.servle

5、t.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.sql.*;public class CheckUserName extends HttpServlet public CheckUserName() super();public void destroy() super.destroy();public void doGet(

6、HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException response.setContentType(text/htmlPrintWriter out = response.getWriter();/接收数据String userName=request.getParameter(/数据库链接tryClass.forName(com.microsoft.jdbc.sqlserver.SQLServerDrivercatch(ClassNotFoundExcepti

7、on e1)e1.printStackTrace();String jdbcURL=jdbc:microsoft:sqlserver:/localhost:1433;DatabaseName=newsConnection conn = null;try conn = DriverManager.getConnection(jdbcURL,sa,lcatch(SQLException e)e.printStackTrace();PreparedStatement pst;trypst = conn.prepareStatement (select * from admin where userN

8、ame=? pst.setString(1,userName);ResultSet rs=pst.executeQuery();boolean isExist=false;if(rs.next()isExist=true; out.println(isExist);catch(SQLException e) out.close();public void doPost(HttpServletRequest request,HttpServletResponse response)public void init() throws ServletException web.xml 配置文件中Se

9、rvlet 说明servletservlet-nameCheckUserNameservlet-class.CheckUserName/servletservlet_mappingurl-pattern/CheckUserName/servlet-mapping2、jsp在线用户显示与数目统计(没有连接数据库):Login.jsp 页面(登陆页面) import=java.sql.* errorPage=DOCTYPE html PUBLIC -/W3C/DTD XHTML 1.0 Transitional/ENhttp:/www.w3.org/TR/xhtml1/DTD/xhtml1-tra

10、nsitional.dtdhtml xmlns=/www.w3.org/1999/xhtmlmeta http-equiv=Content-Type content= /用户登录form1 name= method=postlogin_deal.jsp 用户名: 密&码:pwdSubmit提交resetSubmit2重置login_deal.jsp页面(登陆处理页面,设置的登录用户名和密码要求一样)处理结果Ok.jsp页面(核心代码:统计用户数并进行显示)% page import=java.util.*String username=(String)session.getAttribute(

11、int p=0;ArrayList list;list = (ArrayList)application.getAttribute(userlistif ( list=null ) list = new ArrayList(); list.add(username);else if ( list.indexOf(username)=-1 ) application.setAttribute(, list);ArrayList ollist = (ArrayList)application.getAttribute(out.println(在线用户如下:for (int i=0; iollist

12、.size(); i+) out.println(ollist.get(i) + p+; out.println(在线用户数:+p);二、Jsp+servlet实现数学计算:1、input.Jsp页面(输入数据)计算输入界面 b= select name=oper size=1option value =+-option value=*3/计算iframe name = width=100%/iframe2、myservlet,java页面(完成计算)package com;import javax.servlet.ServletContext;import javax.servlet.htt

13、p.HttpSession;public class myservlet extends HttpServlet protected void doGet(HttpServletRequest request, HttpServletResponse response) doPost(request,response);protected void doPost(HttpServletRequest request, PrintWriter out=response.getWriter();String da = (String)request.getParameter(String db = (String)request.getParameter(String op = (String)request.getParameter(String str = 没有计算结果int a = Integer.parseInt(da);int b = Integer.parseInt(db);int c = 0; if (op.equals() c = a+b; str = a+b= + c; else if (op.equals( c = a-b;a-b= c = a*b;a*b= c = a/b;a/b= servlet实现的计算结果:+str);

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1