第十二周作业

<%@page import="dao.EmlDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>删除邮件</title>
</head>
<body>
    <%
        request.setCharacterEncoding("utf-8");

        int eid = Integer.parseInt(request.getParameter("eid"));
        EmlDao ed = new EmlDao();
        ed.delEml(eid);
    %>
    <script type="text/javascript">
        alert("删除成功!");
    </script>
    <%
        response.sendRedirect("main.jsp");
    %>
</body>
</html>
<%@page import="dao.UserDao"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<html>
<head>
<title>判断</title>
</head>
<body>
    <%
        request.setCharacterEncoding("utf-8");
        String uname = request.getParameter("uname");
        String upwd = request.getParameter("upwd");

        UserDao ud = new UserDao();
        if (ud.login(uname, upwd)) {
    %>
    <script type="text/javascript">
        alert("登录成功!");
    </script>
    <%
        session.setAttribute("uname", uname);
            request.getRequestDispatcher("main.jsp").forward(request,
                    response);
        } else {
    %>
    <script type="text/javascript">
        alert("登录失败,3秒后返回登录界面");
    </script>
    <%
        response.setHeader("refresh", "3;url=login.jsp");
        }
    %>
</body>
</html>
<%@page import="dao.UserDao"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>获取</title>
</head>
<body>
<%
    String uname=request.getParameter("uname");
    String upwd=request.getParameter("upwd");
    String upwd1=request.getParameter("upwd1");

    if (upwd.equals(upwd1)) {
        UserDao sd = new UserDao();
        sd.reg(uname, upwd);
%>
<script type="text/javascript">alert("注册成功!");</script>
<%
        request.getRequestDispatcher("login.jsp").forward(request,response);
    } else {
%>
<script type="text/javascript">alert("注册失败,请重试!");</script>
<%
        request.getRequestDispatcher("reg.jsp").forward(request,response);
    }
%>
    
</body>
</html>
<%@page import="entity.email"%>
<%@page import="dao.EmlDao"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<html>
<head>
<title></title>
</head>
<body>
    <%
    request.setCharacterEncoding("utf-8");
    String sendername=(String)session.getAttribute("uname");
    String addresseename=request.getParameter("addresseename");
    String title=request.getParameter("title");
    String content=request.getParameter("content");
    
    email m=new email();
    m.setSendername(sendername);
    m.setAddresseename(addresseename);
    m.setTitle(title);
    m.setContent(content);
    
    EmlDao ed=new EmlDao();
    ed.addEml(m);
    
    out.print("发送成功,3秒后返回首页");
    response.setHeader("refresh", "3;url=main.jsp");    
 %>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>登录页面</title>
<script type="text/javascript">
    function check() {
        if (loginForm.uname.value == "") {
            alert("请输入账号!");
            return;
        } else if (loginForm.upwd.value == "") {
            alert("请输入密码!");
            return;
        }
        loginForm.submit();
    }
</script>
</head>
<body>
    <form name="loginForm" action="dologin.jsp" method="post">
        用户:<input type="text" name="uname"><br> 
        密码:<input type="password" name="upwd"><br> 
        <input type="button" value="登录" onClick="check()"> 
        <a href="reg.jsp">立即注册账户</a>
    </form>
</body>
</html>
<%@page import="entity.email"%>
<%@page import="dao.EmlDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>主界面</title>
</head>
<body>
    <%
        String uname = (String) session.getAttribute("uname");
    %>
    <h2>首页!!欢迎你<%=uname%></h2>
    <table border="1">
        <tr>
            <th>发件人</th>
            <th>主题</th>
            <th>状态</th>
            <th>时间</th>
            <th>操作</th>

            <%
                EmlDao md = new EmlDao();
                List<email> list = md.getEmailByAddressee(uname);
                
                for (int i = 0; i < list.size(); i++) {
            %>
            <tr>
            <td><%=list.get(i).getSendername()%></td>
            <td><a href="show.jsp?eid=<%=list.get(i).getEid() %>"><%=list.get(i).getTitle() %></a></td>
            <td>
                <%
                    if (list.get(i).getState() == 1) {
                %> <img src="images/sms_unReaded.png" /> <%
                     } else {
                %> <img src="images/sms_readed.png" /> <%
                     }
                %>
            </td>
            <td><%=list.get(i).getTotime()%></td>
            <td><a href="delete.jsp?eid=<%=list.get(i).getEid()%>">删除</a></td>
            <td><a href="write.jsp?reply=<%=list.get(i).getSendername()%>">回复</a></td>            
            </tr>
            <%
                }
            %>                  
    </table>
    <br>
    <a href="write.jsp">新建邮件</a>    
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>注册页面</title>
</head>
<body>
    <form name="regForm" action="doreg.jsp" method="post">
        用户:<input type="text" name="uname"><br> 
        密码:<input type="password" name="upwd" ><br> 
        确认密码:<input type="password" name="upwd1" ><br> 
        <input type="submit" value="注册" > 
        <a href="login.jsp">已有账号?前往登录</a>
    </form>
</body>
</html>
<%@page import="entity.email"%>
<%@page import="dao.EmlDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>查看邮件界面</title>
</head>
<body>
    <%
        request.setCharacterEncoding("utf-8");
        
        String eid = request.getParameter("eid");
        int id = Integer.parseInt(eid);
        EmlDao ed = new EmlDao();
        ed.updateEml(id);
        email m=ed.showEml(id);    
    %>
    <h2>查看邮件</h2>
    <table>
        <tr>
            <td>发件人:</td>
            <td><input type="text" name="sendername" value="<%=m.getSendername()%>"></td>
        </tr>
        <tr>
            <td>发件时间:</td>
            <td><input type="text" name="totime" value="<%=m.getTotime()%>"></td>
        </tr>
        <tr>
            <td>主题:</td>
            <td><input type="text" name="title"    value="<%=m.getTitle()%>"></td>
        </tr>
        <tr>
            <td>内容:</td>
            <td><input type="text" name="content" value="<%=m.getContent()%>"></td>
        </tr>
    </table>

    <a href="main.jsp">返回</a>
</body>
</html>
<%@page import="entity.email"%>
<%@page import="dao.EmlDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>修改界面</title>
</head>
<body>

</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>    
    <title>写邮件</title>
  </head>  
  <body>
  <h2>写邮件</h2>
  <form action="dowrite.jsp">
  收件人:<input name="addresseename" type="text" size="28" value="<%=request.getParameter("reply")%>"><br>
  主题:<input name="title" type="text" size="30"><br>
  内容:<br>
  <textarea name="content" rows="10" cols="34"></textarea><br>
  <input type="submit" value="发送邮件">
  <p>
  <a href="main.jsp">返回</a>
  </p>
  </form>
  
  </body>
</html>

 

 

 

 

 

 

 1.实现 删除 回复邮件
2.实现阅读邮件功能:在main.jsp中点击任意邮件的标题,进入到detail.jsp显示邮件详情,包括发件人,主题,内容,时间。同时需要把邮件状态修改为已读。

 

posted @ 2022-05-20 19:30  卞十三  阅读(7)  评论(0编辑  收藏  举报