第十二周作业

1.实现昨天讲过的 删除 回复邮件
2.实现阅读邮件功能:在main.jsp中点击任意邮件的标题,进入到detail.jsp显示邮件详情,包括发件人,主题,内容,时间。同时需要把邮件状态修改为已读。
3.中间有抽查,抽查到的同学要求2分钟内发上机程序截图给我。

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
<head>




<title>My JSP 'index.jsp' starting page</title>

</head>

<body>
<script type="text/javascript">
        function validate(){
            if(loginForm.uname.value==""){
                alert("账号不能为空!");
                return;
            }
            if(loginForm.upwd.value==""){
                alert("密码不能为空!");
                return;
            }
            loginForm.submit();
        }
    </script>


    <form name="loginForm" action="dologin.jsp" method="post">
        
    用户名:<input type="text" name="uname" value="zs"><br> 
    密码: <input  type="password" name="upwd"  value="123">
    
        <input type="button" value="登录" onClick="validate()">    





    </form>

<a href="zhuce.jsp">注册</a>


</body>
</html>




<%@page import="dao.MsgDao"%>
<%@page import="dao.UsersDao"%>

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    request.setCharacterEncoding("utf-8");
    String uname = request.getParameter("uname");
    String upwd = request.getParameter("upwd");
    UsersDao ud=new UsersDao();
    MsgDao md=new MsgDao();
    if(ud.login(uname, upwd)){
        session.setAttribute("uname", uname);    
        request.getRequestDispatcher("main1.jsp").forward(request, response);
    }else{
        out.print("登陆失败,即将跳回登陆页.....");
        response.setHeader("refresh", "5;url=denglu.jsp");
    }
        
    
    

 %>





<%@page import="java.util.concurrent.Delayed"%>
<%@page import="entity.Msg"%>
<%@page import="dao.MsgDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
<head>




<title>My JSP 'index.jsp' starting page</title>

</head>

<body>
首页!!
<%
    MsgDao md=new MsgDao();
    String uname=(String)session.getAttribute("uname");
    List<Msg> list=md.getMailByReceiver(uname);
    out.print("<table><tr><th>发件人</th><th>主题</th><th>状态</th><th>时间</th></tr>");
    for(int i=0;i<list.size();i++){
        out.print("<tr><td>"+list.get(i).getUsername()+"</td>");
        out.print("<td>"+list.get(i).getTitle()+"</td>");
        out.print("<td>"+list.get(i).getState()+"</td>");
        out.print("<td>"+list.get(i).getMsg_create_date()+"</td>");
        out.print("<td>"+"<a href='huifu.jsp?sendto="+list.get(i).getUsername()+"'>回复</a>"+"</td>");
        out.print("<td>"+"<a href='del.jsp?delid="+list.get(i).getMsgid()+"'>删除</a>"+"</td>");
        out.print("<td>"+"<a href='detail.jsp?msgid="+list.get(i).getMsgid()+"'>查看</a>"+"</td></tr>");
    }
    out.print("</table>");


 %>





</body>
</html>



<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
<form  action="dhuifu.jsp" method="post">
        
    标题:<input type="text" name="title" ><br> 
    内容: <input  type="text" name="msgcontent"  >
    <input  type="hidden" name="sendto"  value="<%=request.getParameter("sendto") %>">
    
        <input type="submit" value="回复" >    





    </form>
</body>
</html>




<%@page import="dao.MsgDao"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String sendto = request.getParameter("sendto");
String msgcontent = request.getParameter("msgcontent");
String title = request.getParameter("title");
String username = (String)session.getAttribute("uname");
MsgDao msg = new MsgDao();
msg.write(username, sendto, title, msgcontent);
%>
</body>
</html>



<%@page import="dao.MsgDao"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String msgId = request.getParameter("delid");
MsgDao md=new MsgDao();
md.del(msgId);
response.sendRedirect("main1.jsp");
%>
</body>
</html>



<%@page import="entity.Msg"%>
<%@page import="dao.MsgDao"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
    String msgid = request.getParameter("msgid");
    MsgDao msgDao = new MsgDao();
    Msg msg = msgDao.search(msgid);
    out.print("<table><tr><th>发件人</th><th>主题</th><th>状态</th><th>时间</th></tr>");
    out.print("<tr><td>"+msg.getUsername()+"</td>");
    out.print("<td>"+msg.getTitle()+"</td>");
    out.print("<td>"+msg.getState()+"</td>");
    out.print("<td>"+msg.getMsg_create_date()+"</td></tr>");
%>
</body>
</html>

 

 

 

 

 

posted @ 2022-05-22 10:53  董澳  阅读(9)  评论(0编辑  收藏  举报