JSP 08课
2021-03-07 15:30
阅读:428
YPE HTML>
标签:receive 标题 sendto enter coding edit 邮件 response border
"com.gd.entity.Msg"%> "com.gd.dao.MsgDao"%> "com.gd.entity.Users"%> "java" import="java.util.*" pageEncoding="utf-8"%> String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> span>"-//W3C//DTD HTML 4.01 Transitional//EN">base href="">My JSP ‘main.jsp‘ starting page "pragma" content="no-cache"> "cache-control" content="no-cache"> "expires" content="0"> "keywords" content="keyword1,keyword2,keyword3"> "description" content="This is my page"> Users u = (Users) session.getAttribute("user"); MsgDao md=new MsgDao(); Listlist=md.getMailByReceiver(u.getUsername()); %> "editemail.jsp">写邮件 "0" cellpadding="0" cellspacing="0" align="center" width="750px">
"100px" height="35px">username "100px" height="35px">title "150px" height="35px">msgcontent "100px" height="35px">state "100px" height="35px">sendto "200px" height="35px">msg_create_date for(int i=0;i){ %> get(i).getMsgid() %> get(i).getUsernname() %> "detail.jsp?id=">get(i).getTitle()%> get(i).getSendto() %> if(list.get(i).getState()==1){ %> "images/sms_unReaded.png"> else{ %> "images/sms_readed.png"> get(i).getMsg_create_date() %> "">回复 "">删除 PreparedStatement ps = null; ResultSet rs = null; try { Class.forName("com.mysql.jdbc.Driver"); //加载驱动 String url = "jdbc:mysql://localhost:3306/jdbcjsp"; String user = "root"; String password = "root"; conn = DriverManager.getConnection(url, user, password); // 连接对象 //conn = BaseDao.getConnection(); %>} catch (Exception e) { e.printStackTrace(); } finally { //BaseDao.closeAll(conn, ps, rs); try { if (rs != null) { rs.close(); } } finally { try { if (ps != null) { ps.close(); } } finally { if (conn != null) { conn.close(); } } } } %>
"java" import="java.util.*" import="java.sql.*" import="com.gd.entity.Msg" pageEncoding="utf-8"%> String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> span>"-//W3C//DTD HTML 4.01 Transitional//EN"> base href="">My JSP ‘insert.jsp‘ starting page "pragma" content="no-cache"> "cache-control" content="no-cache"> "expires" content="0"> "keywords" content="keyword1,keyword2,keyword3"> "description" content="This is my page"> request.setCharacterEncoding("utf-8"); String uuname = (String) session.getAttribute("uuname"); String ctitle = request.getParameter("ctitle"); String ccontent = request.getParameter("ccontent"); String sendtoid = request.getParameter("sendtoid"); //获取邮件列表页面输入的标题 String contitle = (String) session.getAttribute("newcontitle"); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { Class.forName("com.mysql.jdbc.Driver"); //加载驱动 String url = "jdbc:mysql://localhost:3306/jdbcjsp"; String user = "root"; String password = "root"; conn = DriverManager.getConnection(url, user, password); // 连接对象 //conn = BaseDao.getConnection(); %> if(contitle!=null){ Msg msg = new Msg(); ps = conn.prepareStatement("select * from msg where title=?and usernname=?"); ps.setString(1, contitle); ps.setString(2, uuname); rs = ps.executeQuery(); while (rs.next()) { ps = conn.prepareStatement("insert into msg(usernname,title,msgcontent,sendto,state,msg_create_date)" + "values(‘" +sendtoid + "‘,‘" + ctitle + "‘,‘" + ccontent + "‘,‘" + uuname + "‘,‘" + "1" + "‘,‘"+"2020-04-27"+"‘)"); ps.executeUpdate(); request.getRequestDispatcher("index.jsp").forward(request, response); %> } }else{ Msg msg = new Msg(); ps = conn.prepareStatement("insert into msg(usernname,title,msgcontent,sendto,state,msg_create_date)" + "values(‘" + sendtoid + "‘,‘" + ctitle + "‘,‘" + ccontent + "‘,‘" + uuname + "‘,‘" + "1" + "‘,‘"+"2020-04-27"+"‘)"); ps.executeUpdate(); request.getRequestDispatcher("index.jsp").forward(request, response); } %> } catch (Exception e) { e.printStackTrace(); } finally { //BaseDao.closeAll(conn, ps, rs); try { if (rs != null) { rs.close(); } } finally { try { if (ps != null) { ps.close(); } } finally { if (conn != null) { conn.close(); } } } } %>
JSP 08课
标签:receive 标题 sendto enter coding edit 邮件 response border
原文地址:https://www.cnblogs.com/naoguakerteng/p/12883088.html
评论
亲,登录后才可以留言!