当前位置:首页>> >>


网页服务器.rar

收藏

资源目录
    文档预览:
    编号:20181030003753188    类型:共享资源    大小:18.01MB    格式:RAR    上传时间:2018-10-30
    尺寸:148x200像素    分辨率:72dpi   颜色:RGB    工具:   
    35
    金币
    关 键 词:
    网页 服务器
    资源描述:
    JISHOU UNIVERSITY程 序 设 计 基 础课 程 设 计题 目: WebServer作 者: 郭哲成学 号: 20154206249所属学院: 软件学院专业年级: 软件工程 2015 级 4 班指导教师: 宋旭东完成时间: 2016 年 6 月 2 日—2016 年 6 月 12 日软件学院制项目描述目的: java 构建的后台服务器对网页进行相应意义: 更加深入了解 socket 网络编程的知识项目功能目标系统创新点:可以通过电话号码进行找回密码系统主要流程代码登录界面注册 登录输入用户名密码注册用户名密码登录 失败 成功找回密码 更改密码更改密码项目实施1.结构体说明typedef struct act_s{int x;int y;PIMAGE img;int img_index;int alive;int attack_size;} act;act tank1,tank2,tank3,za1,za2,za3,dz,jia,gw,gw2;typedef struct gun_s//子弹坦克结构体{int x;int y;int alive;int speed;} GUN;GUN zd,slug;运用两个结构体来定义子弹,坦克,障碍和怪物。2.文件说明(1)JDBC 连接及数据处理代码:package JDBC;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.SQLException;import com.mysql.jdbc.ResultSet;public class demo {static Connection conn = null;public static void connection(){try {Class.forName(“com.mysql.jdbc.Driver“);conn = DriverManager.getConnection(“jdbc:mysql://localhost:3306/gzc?useUnicode=true} catch (ClassNotFoundException | SQLException e) {// TODO 自动生成的 catch 块e.printStackTrace();}}public static void add(String name, String pwd,String tel) {connection();try {String sql = “insert into user_information(user_name,password,tel_number) values(?,?,?)“;PreparedStatement ps = conn.prepareStatement(sql);ps.setObject(1,name);ps.setString(2,pwd);ps.setString(3,tel);ps.execute();} catch (SQLException e) {e.printStackTrace();}finally{if(conn!=null){try {conn.close();} catch (SQLException e) {// TODO 自动生成的 catch 块e.printStackTrace();}}}}public static void upDate(String name,String pwd) throws SQLException{connection();String sql = “update user_information set password = ? where user_name=?“;PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1, pwd);ps.setString(2, name);ps.executeUpdate();}public static boolean login(String name,String pwd) throws SQLException{connection();boolean x = true;String sql = “SELECT user_name,password FROM user_information where user_name = ?“;PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1, name);ResultSet rs =(ResultSet) ps.executeQuery();while(rs.next()){if(rs.getString(2).equals(pwd)){x = x; }else{x = false;}}return x;}public static boolean isOldPwd(String name,String opwd) throws SQLException{connection();boolean x = false;String sql = “SELECT user_name,password from user_information where user_name=?“;PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1,name);ResultSet rs =(ResultSet) ps.executeQuery();while(rs.next()){System.out.println(rs.getString(2));if(rs.getString(2).equals(opwd)){x = true; }else{x = false;}}return x;}public static boolean isExist(String name) throws SQLException{connection();int x = 0;String sql = “select user_name from user_information WHERE user_name=?“;PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1, name);ResultSet rs =(ResultSet) ps.executeQuery();if(rs.next()){return true;}else{return false;}}public static boolean isRight(String name,String tel) throws SQLException{connection();boolean is = false;String sql = “select tel_number from user_information WHERE user_name=?“;PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1, name);ResultSet rs =(ResultSet) ps.executeQuery();while(rs.next()){if(rs.getString(1).equals(tel)){is = true;}else{is = false;}}return is;}public static String find(String name,String tel) throws SQLException{connection();String number = null;String sql = “select password from user_information WHERE user_name=?“;PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1, name);ResultSet rs =(ResultSet) ps.executeQuery();while(rs.next()){number = rs.getString(1);}return number;}}(2)对登录界面的响应:package servlet;import JDBC.demo;import server.Request;import server.Response;public class LoginServlet extends Servlet{public void doGet(Request req,Response rep) throws Exception {String name = req.getParameter(“uname“);String pwd = req.getParameter(“pwd“);if(demo.isExist(name)){if(demo.login(name,pwd)){rep.println(“欢迎登录“);rep.println(“ body{“);rep.println(“background-image: url(https://timgsa.baidu.com/timg?image“);rep.println(“background-size:1535px 830px;“);rep.println(“登录成功!“);rep.println(“欢迎“).println(name).println(“回来!“);rep.println(“更换密码!“);rep.println(““);}else{rep.println(“出错了!“);rep.println(“ body{“);rep.println(“background-image: url(https://timgsa.baidu.com/timg?image“);rep.println(“background-size:1535px 830px;“);rep.println(“密码错误!请“);rep.println(“重新登录!“);rep.println(“找回密码!“);rep.println(““);}}else{rep.println(“出错了!“);rep.println(“ body{“);rep.println(“background-image: url(https://timgsa.baidu.com/timg?image“);rep.println(“background-size:1535px 830px;“);rep.println(“用户名不存在! 请“);rep.println(“注册!“);rep.println(““);}}
    展开阅读全文
    1
      金牌文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
    0条评论

    还可以输入200字符

    暂无评论,赶快抢占沙发吧。

    关于本文
    本文标题:网页服务器.rar
    链接地址:http://www.gold-doc.com/p-255473.html
    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服客服 - 联系我们
    [email protected] 2014-2018 金牌文库网站版权所有
    经营许可证编号:浙ICP备15046084号-3
    收起
    展开