JSP 07
2021-03-12 04:31
标签:value meta break request text bre HERE trace 邮件列表 JSP 07 标签:value meta break request text bre HERE trace 邮件列表 原文地址:https://www.cnblogs.com/yanzhen108/p/12829477.html@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
DOCTYPE html>
html>
head>
meta charset="utf-8">
title>登录title>
head>
body>
form action="dologin.jsp" method="post">
用户名:input type="text" name="username" value="yxy" />Br> 密码 :input
type="password" name="password" value="123456" />br> input
type="submit" value="登录">
form>
body>
html>
@ 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 heretitle>
head>
body>
request.setCharacterEncoding("utf-8");
String u = request.getParameter("username");
String p = request.getParameter("password");
if (u.equals("yxy")&&p.equals("123456")) {
request.getRequestDispatcher("index.jsp").forward(request, response);
} else {
response.sendRedirect("login.jsp");
}
%>
body>
html>
body>
request.setCharacterEncoding("utf-8");
String uname = request.getParameter("username");
session.setAttribute("uname", username);
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
//加载驱动
String url = "jdbc:mysql://localhost:3306/mydb";
String user = "root";
String password = "root";
conn = DriverManager.getConnection(url, user, password);
// 连接对象
//conn = BaseDao.getConnection();
%>
table align="center">
tr>
td>username td>
td>title td>
td>msgcontent td>
td>state td>
td>sendto td>
td>msg_create_datetd>
tr>
Msg msg = new Msg();
ps = conn.prepareStatement("select * from msg where username=?");
ps.setString(1, uname);
rs = ps.executeQuery();
while (rs.next()) {
%>
tr>
td>=rs.getString("username")%>td>
td>=rs.getString("title")%>td>
td>=rs.getString("msgcontent")%>td>
td>
if (rs.getString("state").equals("1")) {
%>
out.print("未读");
%>
} else {
%>
out.print("已读");
%>
}
%>
td>
td>=rs.getString("sendto")%>td>
td>=rs.getString("msg_create_date")%>td>
tr>
}
%>
table>
form action="content.jsp" method="post">
按标题查询:input type="text" name="contitle"> input type="submit"
value="查询">
form>
br>
} 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();
}
}
}
}
%>
body>
body>
request.setCharacterEncoding("utf-8");
String uname = (String) session.getAttribute("username");
String newstate = null;
//获取邮件列表页面输入的标题
String contitle = request.getParameter("contitle");
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
//加载驱动
String url = "jdbc:mysql://localhost:3306/mydb";
String user = "root";
String password = "root";
conn = DriverManager.getConnection(url, user, password);
// 连接对象
//conn = BaseDao.getConnection();
%>
Msg msg = new Msg();
ps = conn.prepareStatement("select * from msg where title=?and username=?");
ps.setString(1, contitle);
ps.setString(2, uname);
rs = ps.executeQuery();
while (rs.next()) {
%>
form action="" name="huifu" method="post">
sendto =rs.getString("sendto")%>br> br>标题:=rs.getString("title")%>br>
br> 正文:=rs.getString("msgcontent")%>br>
//更新阅读状态
if (rs.getInt("state") == 1) {
ps = conn.prepareStatement("update msg set state=? where state=? and title=?");
// 执行sql语句
ps.setInt(1, 0);
ps.setInt(2, 1);
ps.setString(3, contitle);
ps.executeUpdate();
break;
}
%>
}
%>
form>
form action="insert.jsp" method="post">
session.setAttribute("uuname", uname);
session.setAttribute("newcontitle", contitle);
%>input type="submit" value="回复">
form>
form action="main2.jsp" method="post">
session.setAttribute("uuname", uname);
%>
input type="submit" value="返回邮件列表" name="newyjlb">
form>
form action="delete.jsp" method="post">
session.setAttribute("uuname", uname);
session.setAttribute("newcontitle", contitle);
%>
input type="submit" value="删除邮件" name="deleteyj">
form>
} 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();
}
}
}
}
%>
body>
body>
request.setCharacterEncoding("utf-8");
String uuname = (String) session.getAttribute("uuname");
//获取邮件列表页面输入的标题
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/mydb";
String user = "root";
String password = "root";
conn = DriverManager.getConnection(url, user, password);
// 连接对象
//conn = BaseDao.getConnection();
%>
Msg msg = new Msg();
ps = conn.prepareStatement("select * from msg where title=?and username=?");
ps.setString(1, contitle);
ps.setString(2, uuname);
rs = ps.executeQuery();
while (rs.next()) {
%>
form action="insert2.jsp" name="huifu" method="post">
sendto =rs.getString("sendto")%>br> br>
标题:input type="text" name="ctitle">br> br>
正文:input type="text" name="ccontent">br>
input type="submit" value="发送">
form>
}
%>
} 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();
}
}
}
}
%>
br>
body>
body>
request.setCharacterEncoding("utf-8");
String uuname = (String) session.getAttribute("uuname");
String ctitle = request.getParameter("ctitle");
String ccontent = request.getParameter("ccontent");
//获取邮件列表页面输入的标题
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/mydb";
String user = "root";
String password = "root";
conn = DriverManager.getConnection(url, user, password);
// 连接对象
//conn = BaseDao.getConnection();
%>
Msg msg = new Msg();
ps = conn.prepareStatement("select * from msg where title=?and username=?");
ps.setString(1, contitle);
ps.setString(2, uuname);
rs = ps.executeQuery();
while (rs.next()) {
ps = conn.prepareStatement("insert into msg(username,title,msgcontent,sendto,state,msg_create_date)" + "values(‘"
+ rs.getString("sendto") + "‘,‘" + 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();
}
}
}
}
%>
br>
body>
body>
request.setCharacterEncoding("utf-8");
String uuname = (String) session.getAttribute("uuname");
//获取邮件列表页面输入的标题
//从content.jsp session传过来的
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/mydb";
String user = "root";
String password = "root";
conn = DriverManager.getConnection(url, user, password);
// 连接对象
//conn = BaseDao.getConnection();
%>
table align="center">
tr>
td>username td>
td>title td>
td>msgcontent td>
td>state td>
td>sendto td>
td>msg_create_datetd>
tr>
Msg msg = new Msg();
ps = conn.prepareStatement("delete from msg where title=?and username=?");
// 执行sql语句
ps.setString(1, contitle);
ps.setString(2, uuname);
ps.executeUpdate();
ps = conn.prepareStatement("select * from msg where username=?");
ps.setString(1, uuname);
rs = ps.executeQuery();
while (rs.next()) {
%>
tr>
td>=rs.getString("username")%>td>
td>=rs.getString("title")%>td>
td>=rs.getString("msgcontent")%>td>
td>
if (rs.getString("state").equals("1")) {
%>
out.print("未读");
%>
} else {
%>
out.print("已读");
%>
}
%>
td>
td>=rs.getString("sendto")%>td>
td>=rs.getString("msg_create_date")%>td>
tr>
}
%>
table>
} 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();
}
}
}
}
%>
br>
body>
body>
request.setCharacterEncoding("utf-8");
String uuname = (String) session.getAttribute("uuname");
//获取邮件列表页面输入的标题
//从content.jsp session传过来的
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/mydb";
String user = "root";
String password = "root";
conn = DriverManager.getConnection(url, user, password);
// 连接对象
//conn = BaseDao.getConnection();
%>
table align="center">
tr>
td>username td>
td>title td>
td>msgcontent td>
td>state td>
td>sendto td>
td>msg_create_datetd>
tr>
Msg msg = new Msg();
ps = conn.prepareStatement("delete from msg where title=?and username=?");
// 执行sql语句
ps.setString(1, contitle);
ps.setString(2, uuname);
ps.executeUpdate();
ps = conn.prepareStatement("select * from msg where username=?");
ps.setString(1, uuname);
rs = ps.executeQuery();
while (rs.next()) {
%>
tr>
td>=rs.getString("username")%>td>
td>=rs.getString("title")%>td>
td>=rs.getString("msgcontent")%>td>
td>
if (rs.getString("state").equals("1")) {
%>
out.print("未读");
%>
} else {
%>
out.print("已读");
%>
}
%>
td>
td>=rs.getString("sendto")%>td>
td>=rs.getString("msg_create_date")%>td>
tr>
}
%>
table>
} 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();
}
}
}
}
%>
br>
body>