老年人能力评估的登录注册和部分功能实现及思考

登录:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
</head>
<body>
<form action="index" method="post">
    <label for="type"></label>
    <select id="type">
        <option value="评估员">评估员</option>
        <option value="被评估者">老年人或其照顾者</option>
    </select><br>

    <label for="id">账号:</label>
    <input name="id" type="text" id="id"><br>

    <label for="password">密码:</label>
    <input name="password" type="text" id="password"><br>

    <input type="submit" value="登录">
    <a href="registe.jsp">注册</a>
</form>
</body>
</html>

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/index")
public class index extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String id = request.getParameter("id");
        String password = request.getParameter("password");
        String type = request.getParameter("type");
        indexdata data=new indexdata(id,password);
        Dao dao = new Dao();
        try {
            if(dao.index(data)){
                    request.getSession().setAttribute("id",id);
                    request.getSession().setAttribute("type",type);
                    response.sendRedirect("operator.jsp");
                }
            else {
                    request.getRequestDispatcher("index.jsp").forward(request, response);
                }
            } catch (SQLException | ClassNotFoundException e) {
                e.printStackTrace();
            }
    }
}

public class indexdata {
    private String id;
    private String password;

    public indexdata(String password, String id) {
        this.password = password;
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public String getPassword() {
        return password;
    }
}
注册:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册</title>
</head>
<body>
<form action="registe" method="post">
    <label for="id">账号:</label>
    <input name="id" type="text" id="id"><br>

    <label for="password">密码:</label>
    <input name="password" type="text" id="password"><br>

    <input type="submit" value="注册">
</form>
</body>
</html>

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/registe")
public class registe extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        String password = request.getParameter("password");
        Dao dao = new Dao();
        try {
            if(dao.registe(id,password,"被评估者")){
                response.sendRedirect("operator.jsp");
            }
            else {
                request.getRequestDispatcher("index.jsp").forward(request, response);
            }
        } catch (SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
填写基本信息表:
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Date;
import java.sql.SQLException;

@WebServlet("/addplan")
public class addplan extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String number = request.getParameter("number");
        Date date = Date.valueOf(request.getParameter("date"));
        String reason = request.getParameter("reason");
        plandata data=new plandata(number,date,reason);
        Dao dao=new Dao();
        try {
            if(dao.addplan(data)){
                response.sendRedirect("operator.jsp");
            }
        } catch (SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
对于后续对于老年人及其照护者的功能添加查看评估结果,查看评估表A2被评估者的基本信息,填写A3信息提供者及联系人信息表等功能
posted @   sword_kong  阅读(8)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示