邮件系统2(全套增删改查)
作者:互联网
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <form method="post" action="dologin.jsp"> 用户名:<input type="text" name="name"/> <br><br><br> 密 码:<input type="text" name="password"/><br> <hr> <input type="submit" value="登录"> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ page import="scc.Userdao" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% String name=request.getParameter("name"); String password=request.getParameter("password"); Userdao dao=new Userdao(); if(dao.select(name, password)){ request.getRequestDispatcher("main.jsp").forward(request, response); }else{ response.sendRedirect("login.jsp"); } %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@page import="java.sql.*" %> <%@page import="scc.JDBCUtils" %> <%@page import="scc.Msg" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% String nn=request.getParameter("name"); session.setAttribute("name", nn); %> <% Connection con=null; PreparedStatement st=null; ResultSet rst=null; try{ con=JDBCUtils.getCon(); String sql="select*from msg where sender=?"; st=con.prepareStatement(sql); st.setString(1, nn); rst=st.executeQuery(); Msg m=new Msg(); %> <table border="1" > <tr> <td> 标题</td> <td> 内容</td> <td> 发件人</td> <td>收件人</td> <td> 日期</td> <td> 状态</td> </tr> <% while(rst.next()){ %> <tr> <td> <%=rst.getString("title") %></td> <td> <%=rst.getString("content") %></td> <td> <%=rst.getString("sender") %></td> <td><%=rst.getString("recive") %></td> <td> <%=rst.getString("date") %></td> <td> <%=rst.getString("state") %></td> </tr> <%} %> </table> <% }catch(Exception e){ throw new RuntimeException(e); } finally{ JDBCUtils.closeAll(rst, st, con); } %> <br> <br> <br> <br> <br> <br> <div > <form action="domain.jsp" method="post"> 请输入你的标题 <input type="text" name="t"> <input type="submit" value="搜索标题"> </form> </div> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ page import="scc.Msgdao" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% request.setCharacterEncoding("utf-8"); String tt=request.getParameter("t"); Msgdao d=new Msgdao(); if(d.select1(tt)){ request.getRequestDispatcher("main2.jsp").forward(request, response); }else{ response.sendRedirect("main.jsp"); } %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@page import="java.sql.*" %> <%@page import="scc.JDBCUtils" %> <%@page import="scc.Msg" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% request.setCharacterEncoding("utf-8"); String name=(String)session.getAttribute("name"); String tt=request.getParameter("t"); session.setAttribute("title", tt); Connection con=null; PreparedStatement st=null; ResultSet rst=null; try{ con=JDBCUtils.getCon(); String sql="select*from msg where sender=? and title=? "; st=con.prepareStatement(sql); st.setString(1, name); st.setString(2, tt); rst=st.executeQuery(); %> <% while(rst.next()){ %> 收件人: <%=rst.getString("recive") %> <br><br> 标 题: <%=rst.getString("title") %> <br><br> 内 容: <%=rst.getString("content") %> <% if(rst.getString("state")!=null){ st=con.prepareStatement("update msg set state='已读' where sender=? and title=?"); st.setString(1, name); st.setString(2, tt); st.executeUpdate(); } %> <% } %> <% }catch(Exception e){ throw new RuntimeException(e); } finally{ JDBCUtils.closeAll(rst, st, con); } %> <br><br> <form action="add.jsp"> <input type="submit" value="回复"> </form> <form action="delete.jsp"> <input type="submit" value="删除邮件"> </form> <form action="exist.jsp"> <input type="submit" value="退出系统"> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@page import="java.sql.*" %> <%@page import="scc.JDBCUtils" %> <%@page import="scc.Msg" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% request.setCharacterEncoding("utf-8"); String name=(String)session.getAttribute("name"); String tt=(String)session.getAttribute("title"); Connection con=null; PreparedStatement st=null; ResultSet rst=null; try{ con=JDBCUtils.getCon(); String sql="select*from msg where title=? and sender=?"; st=con.prepareStatement(sql); st.setString(1, tt); st.setString(2, name); rst=st.executeQuery(); while(rst.next()){ %> <form action="add2.jsp" method="post"> 收件人:<%=rst.getString("recive")%><br> <br> 标题:<input type="text" name="title1"><br> <br> 内容:<input type="text" name="content1"><br><br> <input type="submit" value="发送"> </form> <% } }catch(Exception e){ throw new RuntimeException(e); } finally{ JDBCUtils.closeAll(rst, st, con); } %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@page import="java.sql.*" %> <%@page import="scc.JDBCUtils" %> <%@page import="scc.Msg" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% request.setCharacterEncoding("utf-8"); String title1=request.getParameter("title1"); String content1=request.getParameter("content1"); String name=(String)session.getAttribute("name"); String tt=(String)session.getAttribute("title"); Connection con=null; PreparedStatement st=null; ResultSet rst=null; try{ con=JDBCUtils.getCon(); st=con.prepareStatement("select * from msg where title=?and sender=?"); st.setString(1, tt); st.setString(2, name); rst=st.executeQuery(); %> <%while(rst.next()){ st=con.prepareStatement("insert into msg(title,content,sender,recive,date,state)"+"values('"+title1+"','"+content1+"','"+name+"','"+rst.getString("recive")+"','"+rst.getString("date")+"','"+rst.getString("state") +"')" ); st.executeUpdate(); request.getRequestDispatcher("login.jsp").forward(request, response); } %> <% }catch(Exception e){ throw new RuntimeException(e); } finally{ JDBCUtils.closeAll(rst, st, con); } %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@page import="java.sql.*" %> <%@page import="scc.JDBCUtils" %> <%@page import="scc.Msg" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% String name=(String)session.getAttribute("name"); String tle=(String)session.getAttribute("title"); Connection con=null; PreparedStatement st=null; ResultSet rst=null; try{ con=JDBCUtils.getCon(); String sql="delete from msg where sender=? and title=?"; st=con.prepareStatement(sql); st.setString(1, name); st.setString(2,tle); st.executeUpdate(); request.getRequestDispatcher("login.jsp").forward(request, response); }catch(Exception e){ throw new RuntimeException(e); } finally{ JDBCUtils.closeAll(rst, st, con); } %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% response.sendRedirect("login.jsp"); %> </body> </html>
标签:用户名,收件人,改查,标题,发件人,邮件系统,增删 来源: https://www.cnblogs.com/gsfwxj1820/p/12829795.html