zoukankan      html  css  js  c++  java
  • jsp第九次作业

    write

    <%@page import="com.gd.entity.Msg"%>
    <%@page import="com.gd.dao.MsgDao"%>
    <%@ page language="java" import="java.util.*" 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">
    <html>
    <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</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">
    <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    </head>
    
    <body>
        <form action="dowrite.jsp" method="post">
            <p>
                收件人:<input type="text" name="sjr" value=<%=request.getParameter("mailto") %> />
            </p>
            <p>
                标题:<input type="text" name="title" />
            </p>
            <p>
                内容:<input type="text" name="content" />
            </p>
            <input type="submit" value="发送">
        </form>
        
        <a href="main.jsp">返回</a>
    </body>
    </html>

    main

    <%@page import="com.gd.entity.Msg"%>
    <%@page import="com.gd.dao.MsgDao"%>
    <%@page import="com.gd.entity.Users"%>
    <%@ page language="java" import="java.util.*" 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">
    <html>
    <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</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">
    <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    </head>
    
    <body>
        欢迎页面!!!欢迎你!!!<%
        Users u = (Users) session.getAttribute("user");
        out.print(u.getUsername());
        MsgDao md = new MsgDao();
        List<Msg> list = md.getMailByReceiver(u.getUsername());
        out.print(list.size());
    %>
        <a href="write.jsp">写邮件</a>
        <a href="logout.jsp">退出</a>
        <table border="1" width="1000">
            <tr>
                <td>邮件id</td>
                <td>发件人</td>
                <td>标题</td>
                <td>收件人</td>
                <td>状态</td>
                <td>时间</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
    
            <%
                for (int i = 0; i < list.size(); i++) {
            %>
            <tr>
                <td><%=list.get(i).getMsgid()%></td>
                <td><%=list.get(i).getUsername()%></td>
                <td><a href="detail.jsp?id=<%=list.get(i).getMsgid()%>"><%=list.get(i).getTitle()%></a>
                </td>
                <td><%=list.get(i).getSendto()%></td>
                <td>
                    <%
                        if (list.get(i).getState() == 0) {
                    %> <img
                    src="images/sms_unReaded.png"></img> <%
         } else {
     %> <img
                    src="images/sms_readed.png"></img> <%
         }
     %>
                </td>
                <!-- 0已读,1未读 -->
                <td><%=list.get(i).getMsg_create_date()%></td>
                
                <td><a href="write.jsp?mailto=<%=list.get(i).getUsername() %>">回复</a>
                </td>
                <td> <a href="delete.jsp?delid=<%=list.get(i).getMsgid()%>">   删除</a>
                </td>
    
            </tr>
    
    
    
            <%
                }
            %>
    
    
        </table>
    
    
    </body>
    </html>

    logout

    <%@page import="com.gd.entity.Users"%>
    <%@page import="com.gd.entity.Msg"%>
    <%@page import="com.gd.dao.MsgDao"%>
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
        session.removeAttribute("user");
        request.getRequestDispatcher("index.jsp").forward(request, response);
    %>

    index

    <%@ page language="java" import="java.util.*" 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">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</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">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
      </head>
      
      <body>
       <form action="dologin.jsp" method="post">
    用户名:<input type="text" name="uname" value="小白" /><Br>
    密码 :<input type="password" name="upwd" value="88888"/><br>
    
    <input type="submit" value="登录">
    
    </form>
      </body>
    </html>

    dowrite

    <%@page import="com.gd.entity.Users"%>
    <%@page import="com.gd.entity.Msg"%>
    <%@page import="com.gd.dao.MsgDao"%>
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
        Users u = (Users) session.getAttribute("user");
        String uname = request.getParameter("sjr");
        String title = request.getParameter("title");
        String content = request.getParameter("content");
        Msg m = new Msg();
        m.setUsernname(u.getUsername());//发件人  登陆者
        m.setSendto(uname);//收件人: 上一页面填写的
        m.setTitle(title);
        m.setMsgcontent(content);
        MsgDao md = new MsgDao();
        md.addMsg(m);
        request.getRequestDispatcher("main.jsp").forward(request, response);
    %>

    dologin

    <%@page import="com.gd.entity.Users"%>
    <%@page import="com.gd.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();
        if (ud.login(uname, upwd)){        
        //登录成功,创建User对象,并放入session
            Users u=new Users();
            u.setUsername(uname);
            u.setPassword(upwd);
            session.setAttribute("user", u);
            request.getRequestDispatcher("main.jsp").forward(request, response);
        }
        else
            response.sendRedirect("index.jsp");
    %>

    detail

    <%@page import="com.gd.entity.Msg"%>
    <%@page import="com.gd.dao.MsgDao"%>
    <%@ page language="java" import="java.util.*" 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">
    <html>
    <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</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">
    <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    </head>
    
    <body>
        <%
            int id = Integer.parseInt(request.getParameter("id"));
            MsgDao md = new MsgDao();
            Msg m = md.getMailById(id);
            md.alterMsg(m.getMsgid());
        %>
        <p>
            题目:<%=m.getTitle()%></p>
        <p>
            来自:<%=m.getUsername()%></p>
        <p>
            时间:<%=m.getMsg_create_date()%></p>
        <p>
            内容:<%=m.getMsgcontent()%></p>
    回复   <a href="main.jsp">返回</a>
    </body>
    </html>

    delete

    <%@page import="com.gd.entity.Users"%>
    <%@page import="com.gd.entity.Msg"%>
    <%@page import="com.gd.dao.MsgDao"%>
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
        int id = Integer.parseInt(request.getParameter("delid"));
    
        MsgDao md = new MsgDao();
        md.delMsg(id);
        request.getRequestDispatcher("main.jsp").forward(request, response);
    %>

  • 相关阅读:
    Tomcat的配置
    读《大道至简》总结
    manjaro安装minishift
    minishift 部署mysql持久化
    从大神到小白之路minishift 命令补全
    Typora 完美结合 PicGo,写作体验更佳!
    40 个笑到抽筋的神回复,绝了!
    如何写出让同事好维护的代码?
    Google的面试题长啥样?看完被吊打
    Mac 超详细入门指南,备用!
  • 原文地址:https://www.cnblogs.com/xiaohusha/p/12934596.html
Copyright © 2011-2022 走看看