基于javaweb的JSP+Servlet新闻管理系统(java+javaweb+jdbc)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

080023032402

090023032402

100023032402

基于javaweb的JSP+Servlet新闻管理系统(java+javaweb+jdbc)

功能介绍:

登录、注册、新闻发布、新闻管理、公告发布、用户管理、退出登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
	 		     out.println("<html>");
out.println("<head>");
out.print("<style>a:link,a:visited,a:hover,a:active{text-decoration: none;color:53bcf8;align:center;}</style>");
out.print("</head>");
out.print("<body>");
out.print("<a href=manage.jsp align=center>该新闻不存在</a>");
out.println("</body></html>");
}
}
catch (Exception e) {
// TODO: handle exception
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<head>");
out.print("<style>a:link,a:visited,a:hover,a:active{text-decoration: none;color:53bcf8;align:center;}</style>");
out.print("</head>");
out.print("<body>");
out.print("<a href=manage.jsp align=center>新闻id错误</a>");
out.println("</body></html>");
}

}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response);
}


}
package Servlet;




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
	 	  	if(news.findID(uid)){
news.Update(uid, title, nid, content,time);
response.sendRedirect("manage.jsp");
}
else{
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<head>");
out.print("<style>a:link,a:visited,a:hover,a:active{text-decoration: none;color:53bcf8;align:center;}</style>");
out.print("</head>");
out.print("<body>");
out.print("<a href=manage.jsp align=center>该新闻不存在</a>");
out.println("</body></html>");
}
}
catch (Exception e) {
// TODO: handle exception
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<head>");
out.print("<style>a:link,a:visited,a:hover,a:active{text-decoration: none;color:53bcf8;align:center;}</style>");
out.print("</head>");
out.print("<body>");
out.print("<a href=manage.jsp align=center>新闻id错误</a>");
out.println("</body></html>");
}

}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response);
}


}
package Servlet;



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
	      byte titles[]=title.getBytes("ISO-8859-1");
title=new String(titles);

String nid=request.getParameter("nid");
byte nids[]=nid.getBytes("ISO-8859-1");
nid=new String(nids);

String content=request.getParameter("content");
byte contents[]=content.getBytes("ISO-8859-1");
content=new String(contents);

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

News news=new News();
news.getConn();
news.insertUser(title,nid,content,time);
response.sendRedirect("insertNews.jsp");
}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response);
}


}
package Servlet;




public class insertMessage extends HttpServlet {

@Override
public void init(ServletConfig config) throws ServletException {
// TODO Auto-generated method stub
super.init(config);
}
public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
response.setContentType("text/html;charset=utf-8");

String content=request.getParameter("content");
byte contents[]=content.getBytes("ISO-8859-1");
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
	     else{
response.sendRedirect("passwordupdate.jsp");
}
}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response);
}


}
package Servlet;






public class deleteNews extends HttpServlet{
public void init(ServletConfig config) throws ServletException{
super.init(config);
}
public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
response.setContentType("text/html;charset=utf-8");
String id=request.getParameter("uid");
try{
int uid=(int)Integer.parseInt(id);
News news=new News();
news.getConn();
if(news.findID(uid)){
news.delete(uid);
response.sendRedirect("manage.jsp");
}
else{
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<head>");
out.print("<style>a:link,a:visited,a:hover,a:active{text-decoration: none;color:53bcf8;align:center;}</style>");
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
	      String content=request.getParameter("content");
byte contents[]=content.getBytes("ISO-8859-1");
content=new String(contents);

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

try{
int uid=Integer.parseInt(id);
News news=new News();
news.getConn();
if(news.findID(uid)){
news.Update(uid, title, nid, content,time);
response.sendRedirect("manage.jsp");
}
else{
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<head>");
out.print("<style>a:link,a:visited,a:hover,a:active{text-decoration: none;color:53bcf8;align:center;}</style>");
out.print("</head>");
out.print("<body>");
out.print("<a href=manage.jsp align=center>该新闻不存在</a>");
out.println("</body></html>");
}
}
catch (Exception e) {
// TODO: handle exception
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<head>");
out.print("<style>a:link,a:visited,a:hover,a:active{text-decoration: none;color:53bcf8;align:center;}</style>");
out.print("</head>");
out.print("<body>");
out.print("<a href=manage.jsp align=center>新闻id错误</a>");
out.println("</body></html>");
}

}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response);
}


}
package Servlet;



项目链接:
https://javayms.github.io?id=521422282105200dv
https://javayms.pages.dev?id=521422282105200dv