Java+Servlet+JSP实现Web宠物诊所管理系统(上)

简介: Java+Servlet+JSP实现Web宠物诊所管理系统

一、系统介绍


软件环境

IDEA:2018.2

Java:jdk1.8

Mysql:8.0.13

Tomcat:8.5.23


系统功能

1.用户的注册与登录

2.宠物信息的增删改查

3.医生信息的增删改查。


数据库涉及的表

userinfo

petdoctor

petdetalis


二、系统展示


1.登录


20210124183149417.jpg


2.注册


20210124183318402.jpg



3.宠物查询主页面


20210124183407568.jpg


4.宠物查询结果


20210124183443251.jpg


5.宠物信息修改


20210124183511764.jpg



6.宠物信息新增


20210124183545296.jpg


7.医生查询主界面


20210124183639230.jpg


8.医生查询结果


20210124183748247.jpg


9.医生信息修改


20210124183803192.jpg


10.医生信息新增


20210124183816245.jpg


三、代码实现


1.前端


init.jsp

<%@ page language="java" pageEncoding="UTF-8" %>
<%
    session.setAttribute("error", "test");
%>
<jsp:forward page="login.jsp"></jsp:forward>

login.jsp

<%@ page language="java" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">
    <title>请登录</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="css/css.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        #content {
            position: relative;
            top: 3px;
            width: 80%;
            height: 380px;
            margin: auto;
            overflow: hidden;
            z-index: 2;
        }
        .tab1 {
            position: relative;
            top: 100px;
            font-size: 24px;
        }
        #in1 {
            width: 250px;
            height: 30px;
            font-size: 24px;
        }
        #in3 {
            width: 250px;
            height: 30px;
            font-size: 24px;
        }
        #in2 {
            width: 80px;
            height: 28px;
        }
    </style>
    <script type="text/javascript">
        function checkId() {
            if (document.getElementById("in1").value == ""
                && document.getElementById("in3").value == "") {
                alert("请输入用户名和密码!");
                return false;
            } else if (document.getElementById("in1").value == "") {
                alert("请输入用户名");
                return false;
            } else if (document.getElementById("in3").value == "") {
                alert("请输入密码!");
                return false;
            } else {
                return true;
            }
        }
    </script>
</head>
<body>
<%
    if (session.getAttribute("error").equals("error")) {
%>
<script type="text/javascript">
    alert("用户名或密码错误请重新登录!");
</script>
<%
    }
    session.setAttribute("error", "test");
%>
<div id="top">
    <font class="topc">宠物诊所</font>
</div>
<center>
    <div id="content">
        <form action="servlet/loginservlet" method="post" onsubmit="return checkId()">
            <table border="0" cellpadding="0" cellspacing="2" class="tab1">
                <tr align="center">
                    <td>用户名</td>
                    <td><input type="text" name="username" id="in1"/></td>
                </tr>
                <tr align="center">
                    <td>密 &nbsp;码</td>
                    <td><input type="password" name="password" id="in3"/></td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <input type="submit" value="登录" id="in2"/>
                        <input type="reset" value="重置" id="in2"/>
                        <a href="adduser.jsp"><font color="gray" size="3"><i>注册</i></font></a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</center>
<!-- include footer -->
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>

adduser.jsp

<%@ page language="java" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">
    <title>注册</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="css/css.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        #content {
            position: relative;
            top: 3px;
            width: 80%;
            height: 380px;
            margin: auto;
            overflow: hidden;
            z-index: 2;
        }
        .tab1 {
            position: relative;
            top: 60px;
            font-size: 24px;
        }
        #in1, #in2, #in3, #in4 {
            width: 250px;
            height: 30px;
            font-size: 24px;
        }
        #in5 {
            width: 80px;
            height: 28px;
            margin-top: 10px;
        }
    </style>
    <script type="text/javascript">
        function checkId() {
            if (document.getElementById("in1").value == ""
                && document.getElementById("in3").value == "" && document.getElementById("in2").value == "") {
                alert("请输入注册用户名和密码!");
                return false;
            } else if (document.getElementById("in1").value == "") {
                alert("请输入用户名");
                return false;
            } else if (document.getElementById("in3").value == "") {
                alert("请输入密码!");
                return false;
            } else if (document.getElementById("in2").value == "") {
                alert("请输入确认密码!");
                return false;
            } else if (document.getElementById("in3").value != document.getElementById("in2").value) {
                alert("您两次的密码不相同!");
                document.getElementById("in2").value = "";
                document.getElementById("in3").value = "";
                return false;
            } else {
                return true;
            }
        }
    </script>
</head>
<body>
<div id="top">
    <font class="topc">注册</font>
</div>
<center>
    <div id="content">
        <br/>
        <form action="servlet/addUserSer" method="post" onsubmit="return checkId()">
            <table border="0" cellpadding="0" cellspacing="2" class="tab1">
                <tr align="center">
                    <td>用户名&nbsp;</td>
                    <td><input type="text" name="name" id="in1"/>*
                    </td>
                </tr>
                <tr align="center">
                    <td>密 码&nbsp;</td>
                    <td><input type="password" name="password" id="in3"/>*
                    </td>
                </tr>
                <tr align="center">
                    <td>确认密码&nbsp;</td>
                    <td><input type="password" id="in2"/>*
                    </td>
                </tr>
                <tr align="center">
                    <td>电 话&nbsp;</td>
                    <td><input type="text" name="phone" id="in4"/>&nbsp;&nbsp;
                    </td>
                </tr>
                <tr align="center">
                    <td colspan="2">
                        <input type="submit" value="提交" id="in5"/>
                        <input type="reset" value="重置" id="in5"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</center>
<!-- include footer -->
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>

adderr.jsp

<%@ page language="java" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">
    <title>失败</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="css/css.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        #content {
            position: relative;
            top: 3px;
            width: 80%;
            height: 380px;
            margin: auto;
            overflow: hidden;
            font-size: 30px;
            z-index: 2;
        }
    </style>
</head>
<body>
<div id="top">
    <font class="topc">注册失败</font>
</div>
<center>
    <div id="content">
        <br/><br/>
        <br/>(╯﹏╰) 注册失败,返回重新注册 <a href="adduser.jsp">
        <font color="blue">
            <i>返回</i>
        </font>
    </a>
    </div>
</center>
<!-- include footer -->
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>

addsuc.jsp

<%@ page language="java" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">
    <title>恭喜注册成功</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="refresh" content="3;url=../init.jsp">
    <link href="css/css.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        #content {
            position: relative;
            top: 3px;
            width: 80%;
            height: 380px;
            margin: auto;
            overflow: hidden;
            font-size: 30px;
            z-index: 2;
        }
    </style>
</head>
<body>
<div id="top">
    <font class="topc">注册成功</font>
</div>
<center>
    <div id="content">
        <br/><br/>
        <br/> (*^__^*)恭喜您注册成功!3s后返回登录页面 <a href="init.jsp">
        <font color="red">
            <i>立即返回</i>
        </font>
    </a>
    </div>
</center>
<!-- include footer -->
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>

petadd.jsp

<%@ page language="java" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">
    <title>宠物新增</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="css/css.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        #content {
            position: relative;
            top: 3px;
            width: 80%;
            height: 380px;
            margin: auto;
            overflow: hidden;
            z-index: 2;
        }
        .tab1 {
            position: relative;
            top: 60px;
            font-size: 24px;
        }
        #in1, #in2, #in3, #in4 ,#in6{
            width: 250px;
            height: 30px;
            font-size: 24px;
        }
        #in5 {
            width: 80px;
            height: 28px;
            margin-top: 10px;
        }
    </style>
    <script type="text/javascript">
        function checkId() {
            if (document.getElementById("in1").value == ""
                && document.getElementById("in3").value == ""
                && document.getElementById("in2").value == ""
                && document.getElementById("in6").value == "") {
                alert("请输入宠物名相关信息!");
                return false;
            } else if (document.getElementById("in1").value == "") {
                alert("请输入宠物名!");
                return false;
            } else if (document.getElementById("in3").value == "") {
                alert("请输入主人!");
                return false;
            }else if (document.getElementById("in6").value == "") {
                alert("请输入电话!");
                return false;
            }
            else {
                return true;
            }
        }
    </script>
</head>
<body>
<jsp:include page="top.jsp"></jsp:include>
<!-- include top -->
<center>
    <div id="content">
        <br/>
        <form action="servlet/petadd" method="post" onsubmit="return checkId()">
            <table border="0" cellpadding="0" cellspacing="2" class="tab1">
                <tr align="center">
                    <td>宠物名&nbsp;</td>
                    <td><input type="text" name="petname" id="in1"/>*
                    </td>
                </tr>
                <tr align="center">
                    <td>主人&nbsp;</td>
                    <td><input type="text" name="petmaster" id="in3"/>*
                    </td>
                </tr>
                <tr align="center">
                    <td>城市&nbsp;</td>
                    <td><input type="text" name="petcity" id="in4"/>&nbsp;&nbsp;
                    </td>
                </tr>
                <tr align="center">
                    <td>地址&nbsp;</td>
                    <td><input type="text" name="petadress" id="in2"/>&nbsp;&nbsp;
                    </td>
                </tr>
                <tr align="center">
                    <td>电话&nbsp;</td>
                    <td><input type="text" name="petphone" id="in6"/>*
                    </td>
                </tr>
                <tr align="center">
                    <td colspan="2">
                        <input type="submit" value="提交" id="in5"/>
                        <input type="reset" value="重置" id="in5"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</center>
<!-- include footer -->
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>
相关文章
|
4天前
|
Java
学院管理系统【JSP+Servlet+JavaBean】(Java课设)
学院管理系统【JSP+Servlet+JavaBean】(Java课设)
21 3
学院管理系统【JSP+Servlet+JavaBean】(Java课设)
|
4天前
|
Java
排课系统【JSP+Servlet+JavaBean】(Java课设)
排课系统【JSP+Servlet+JavaBean】(Java课设)
18 5
|
4天前
|
Java
仓库管理系统【JSP+Servlet+JavaBean】(Java课设)
仓库管理系统【JSP+Servlet+JavaBean】(Java课设)
15 1
|
3天前
|
存储 运维 Java
java云his系统源码一站式诊所SaaS系统Java版云HIS系统 八大特点
HIS系统采用面向技术架构的分析与设计方法,应用多层次应用体系架构设计,运用基于构件技术的系统搭建模式与基于组件模式的系统内核结构。通过建立统一接口标准,实现数据交换和集成共享,通过统一身份认证和授权控制,实现业务集成、界面集成。
28 1
|
4天前
|
开发框架 缓存 Java
JSP 教程 之 Eclipse JSP/Servlet 环境搭建 1
本教程指导如何使用Eclipse搭建JSP/Servlet开发环境。需下载Eclipse J2EE和Tomcat,将Tomcat解压至无中文和空格的D盘目录。启动Tomcat后,服务器运行,通过浏览器访问`http://localhost:8080/`。在Tomcat的webapps\ROOT目录创建test.jsp文件,输入代码并访问`http://localhost:8080/test.jsp`以验证环境配置成功。
7 1
|
4天前
|
Java
校园帮【JSP+Servlet+JavaBean】(Java课设)
校园帮【JSP+Servlet+JavaBean】(Java课设)
9 1
|
4天前
|
Java
新闻发布系统【JSP+Servlet+JavaBean】(Java课设)
新闻发布系统【JSP+Servlet+JavaBean】(Java课设)
12 2
|
4天前
|
Java
学校人员管理系统【JSP+Servlet+JavaBean】(Java课设)
学校人员管理系统【JSP+Servlet+JavaBean】(Java课设)
13 2
|
Java
Java学习路线-55:自定义JSP标签
Java学习路线-55:自定义JSP标签
81 0
Java学习路线-55:自定义JSP标签
Java学习路线-55:自定义JSP标签