首页 > 其他分享 >河北省环保建设新闻报告系统(上)

河北省环保建设新闻报告系统(上)

时间:2023-02-13 19:34:12浏览次数:50  
标签:String rs 河北省 新闻 alert 环保 jsp print out

管理员界面

浏览

<%@ page language="java" import="java.sql.*" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.Util.util" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>新闻浏览.</title>
</head>
<body>


<table border="1" cellspacing="0" style="text-align:center;">
<tr>
<td align="center" width=6%>新闻标题</td>
<td align="center" width=10%>作者</td>
<td align="center" width=6%>关键字</td>
</tr>
<%
Connection connection = util.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from news";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){

%>
<tr>
<td align="center"><a href='Admin_Liulan_back1.jsp?name=<%=rs.getObject(1)%>'><%=rs.getObject(1) %></a></td>
<td align="center"><%=rs.getObject(2)%></td>
<td align="center"><%=rs.getObject(3) %></td>
</tr>
<%

}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
%>
</table>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<input type="button" name="back" onclick="javascript:window.history.back();" value=返回上一页>

<input type="button" value="返回菜单" onclick="location.href='Admin_Menu.jsp'" /> <br>

</p>
</body>
</html>

liulan-back1.jsp

<%@ page language="java" import="java.sql.*" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.Util.util" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>详细房产信息</title>
</head>
<body>

<%
String name = (String)request.getParameter("name");
Connection connection = util.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from news";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(name.equals(rs.getObject(1)))
{
//重要
String writer= (String) rs.getObject(2);
session.setAttribute("writer",writer);
%>
<table border="1"cellspacing="0"style="text-align:center;">
<tr>
<td align="center" width=5%>新闻标题</td>
<td align="center" width=5%>作者</td>
<td align="center" width=10%>关键字</td>
<td align="center" width=5%>日期</td>
<td align="center" width=5%>内容</td>
<td align="center" width=5%>通过状态</td>
</tr>
<tr>
<td align="center"><%=rs.getObject(1) %></td>
<td align="center"><%=rs.getObject(2) %></td>
<td align="center"><%=rs.getObject(3) %></td>
<td align="center"><%=rs.getObject(4) %></td>
<td align="center"><%=rs.getObject(5) %></td>
<td align="center"><%=rs.getObject(6) %></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
%>
</table>
<form action="Admin_Liulan_back2.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<br>
点击按钮通过审核
<br>
<input type="submit" value="通过" >
</p>
</form>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<input type="button" name="back" onclick="javascript:window.history.back();" value=返回上一页>
<input type="button" value="返回菜单" onclick="location.href='Admin_Menu.jsp'" /> <br>
</p>
</body>
</html>

liulan-back2.jsp

<%@ page import="com.Dao.dao" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
<%

String name= (String) session.getAttribute("name");
String test="yes";
dao dao=new dao();
dao.CheckNews(test,name);
out.print("<script language='javaScript'> alert('成功通过审核');</script>");
response.setHeader("refresh", "0;url=Admin_Menu.jsp");

%>
</table>
</body>
</html>

login.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>登录</title>
</head>
<body>
<form action="Admin_Login_back.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
管理员登录
<br>
工号
<input type="text" name="AdminID" >
<br>
密码
<input type="text" name="Apassword" >
<br>
<input type="submit" value="登录" >
</p>
</form>
</body>
</html>

login_back.jsp

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="com.Util.util" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
<%
String AdminID=(String)request.getParameter("AdminID");

session.setAttribute("AdminID",AdminID);

String Apassword=(String)request.getParameter("Apassword");

session.setAttribute("Apassword",Apassword);

if(AdminID==""||Apassword=="")
{
out.print("<script language='javaScript'> alert('工号或密码输入为空'); window.history.back(); </script>");
}
else
{

int i=0;
Connection connection = util.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql= " select * from Admin ";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next())
{
if(AdminID.equals(rs.getObject(1))&&Apassword.equals(rs.getObject(2)))
{i++;}
}
if(i==0)
{
out.print("<script language='javaScript'> alert('工号或密码错误'); window.history.back(); </script>");
}
else
{
out.print("<script language='javaScript'> alert('登录成功');</script>");
response.setHeader("refresh", "0;url=Admin_Menu.jsp");
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
}
%>
</table>
</body>
</html>

Menu.jsp

<%@ page language= "java" contentType= "text/html; charset=UTF-8"
pageEncoding= "UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<h1 align = "center">管理员系统</h1><br>
</head>
<body>
<div align = "center"> <a href="Admin_Liulan.jsp">浏览并管理待发新闻</button ></a></div><br>
<div align = "center"> <a href="update.html">浏览并管理已发新闻</button></a></div><br>
</body>
</html>

write_back.jsp

<%@ page import="java.sql.SQLException" %>
<%@ page import="com.Bean.bean" %>
<%@ page import="com.Dao.dao" %>
<%@ page language= "java" import="java.util.*" contentType= "text/html; charset=UTF-8"
pageEncoding= "UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta charset="UTF-8">

<%

String name = request.getParameter("name");
String writer = request.getParameter("writer");
String type = request.getParameter("type");
String time = request.getParameter("time");
String neirong = request.getParameter("neirong");


if(name=="")
{
out.print("<script language='javaScript'> alert('学生ID输入为空'); window.history.back(); </script>");
}

else if(writer=="")
{
out.print("<script language='javaScript'> alert('密码输入为空'); window.history.back(); </script>");
}
else if(type=="")
{
out.print("<script language='javaScript'> alert('班级输入为空'); window.history.back(); </script>");
}
else if(time=="")
{
out.print("<script language='javaScript'> alert('学生姓名输入为空'); window.history.back(); </script>");
}
else if(neirong=="")
{
out.print("<script language='javaScript'> alert('性别输入为空'); window.history.back(); </script>");
}
else
{
bean bean = new bean();
bean.setName(name);
bean.setWriter(writer);
bean.setType(type);
bean.setTime(time);
bean.setNeirong(neirong);
dao dao = new dao();
dao.AddNews(bean);
out.print("<script language='javaScript'> alert('撰写成功');</script>");
response.setHeader("refresh", "0;url=Writer_Menu.jsp");
}
%>
</html>

user change.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>修改密码</title>
</head>
<body>
<form action="User_Change_back.jsp" method="get">
<p style="text-align:center;font-size:20px" >
密码修改
<br>
旧密码
<input type="text" name="Password0">
<br>
新密码
<input type="password" name="Password1">
<br>
请再次输入新密码
<input type="password" name="Password2">
<br>
<input type="submit" value="修改">
</p>
</form>
</body>
</html>

user_change_back,jsp

<%@ page import="com.Dao.dao" %>
<%@ page import="java.util.Objects" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<%
String UserID= (String) session.getAttribute("UserID");
String Password2=(String)request.getParameter("Password2");

String Spassword= (String) session.getAttribute("Upassword");
String Password0=(String)request.getParameter("Password0");
String Password1=(String)request.getParameter("Password1");

if(!Password0.equals(Spassword))
{
out.print("<script language='javaScript'> alert('旧密码输入错误');window.history.back();</script>");
}
else if(Password0==""||Password1==""||Password2=="")
{
out.print("<script language='javaScript'> alert('输入为空');window.history.back();</script>");
}
else if(!Password2.equals(Password1))
{
out.print("<script language='javaScript'> alert('新密码两次输入不一致');window.history.back();</script>");
}
else
{
dao dao=new dao();

dao.ChangeUserPassword(Password2,UserID);
out.print("<script language='javaScript'> alert('修改成功,即将重新登录');</script>");
response.setHeader("refresh", "0;url=User_Login.jsp");
}
%>

</body>
</html>

user_login,jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>登录</title>
</head>
<body>
<form action="User_Login_back.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
用户登录
<br>
账号
<input type="text" name="UserID" >
<br>
密码
<input type="text" name="Upassword" >
<br>
<input type="submit" value="登录" >
</p>
</form>
</body>
</html>

user -login -back,jsp

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="com.Util.util" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
<%
String UserID=(String)request.getParameter("UserID");

session.setAttribute("UserID",UserID);

String Upassword=(String)request.getParameter("Upassword");

session.setAttribute("Upassword",Upassword);

if(UserID==""||Upassword=="")
{
out.print("<script language='javaScript'> alert('工号或密码输入为空'); window.history.back(); </script>");
}
else
{

int i=0;
Connection connection = util.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql= " select * from abc ";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next())
{
if(UserID.equals(rs.getObject(1))&&Upassword.equals(rs.getObject(2)))
{i++;}
}
if(i==0)
{
out.print("<script language='javaScript'> alert('工号或密码错误'); window.history.back(); </script>");
}
else
{
out.print("<script language='javaScript'> alert('登录成功');</script>");
response.setHeader("refresh", "0;url=User_Menu.jsp");
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
}
%>
</table>
</body>
</html>

uesr_Menu,jsp

<%@ page language= "java" contentType= "text/html; charset=UTF-8"
pageEncoding= "UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<h1 align = "center">用户系统</h1><br>
</head>
<body>
<div align = "center"> <a href="User_Watch.jsp">浏览相应栏目新闻</button ></a></div><br>
<div align = "center"> <a href="User_Talk.html">用户评论新闻</button></a></div><br>
<div align = "center"> <a href="User_Other.jsp">浏览其他用户评论</button></a></div><br>
<div align = "center"> <a href="User_Change.jsp">修改密码</button></a></div><br>
</body>
</html>

user search .jsp

%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>新闻查询</title>
</head>
<body>
<form action="User_Search_part.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
请输入要查询的新闻标题/作者/关键字/日期(模糊查询)
<br>
<input type="text" name="data">
<br>
<input type="submit" value="提交" >
<input type="reset" value="重置" >
<br>
<input type="button" value="返回主菜单" onclick="location.href='Admin_Menu.jsp'">
<br>
</p>
</form>
</body>
</html>

 

标签:String,rs,河北省,新闻,alert,环保,jsp,print,out
From: https://www.cnblogs.com/ruipengli/p/17117510.html

相关文章