Student union management system based on Java

Posted by coreycollins on Sat, 11 Sep 2021 00:18:07 +0200

Project technology:

Back end: servlet

Front end: bootstrap, kindedit, JS, CSS, AJAX, etc

Development tool: eclipse

Database: mysql 5.7

JDK version: jdk1.8

Server: tomcat8

Project introduction:

The system adopts java language, servlet development and mysql database, which is suitable for ordinary students. The system is divided into two roles: administrator and student union member, including reference papers. Functions include: student union public information viewing, activity understanding, registered members, registered members can publish activities, activities need to be reviewed by the administrator, and personal information can be maintained. The administrator can publish announcement information, activity review, etc. the published information can include text, pictures and other information.

Document details:

 

Display of some functions:

System home page: you can view all announcement information

details

Select a public information and click to view the details

Activity information

The activity information applied by the student union can only be displayed after being reviewed by the administrator

Activity details

View activity details

Member information

Show all members of the student union

Student union member registration

Registration system

User background - personal information

View personal information

User background - activity management

You can apply for activities

User background - add activity

You can add text or pictures

Administrator - public information maintenance

Maintain public information

Administrator - activity audit

Audit user initiated activities

Administrator - user management

user management

  Part code:

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

		response.setContentType(Constant.CONTENTTYPE);
		request.setCharacterEncoding(Constant.CHARACTERENCODING);
		HttpSession session = request.getSession();
		ComBean cBean = new ComBean();
		String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
		String date2=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
		String method = request.getParameter("method");
		if(method.equals("mreg")){ //User registration
			String username = request.getParameter("username"); 
			String password = request.getParameter("password"); 
			String realname = request.getParameter("realname"); 
			String sex = request.getParameter("sex"); 
			String age = request.getParameter("age"); 
			String address = request.getParameter("address"); 
			String email = request.getParameter("email");
			String zy = request.getParameter("zy");
			String bm = request.getParameter("bm");
			
			if(username.equals("admin")){
				request.setAttribute("message", "Illegal user name!");
				request.getRequestDispatcher("reg.jsp").forward(request, response); 
			}
			else{
				String str=cBean.getString("select id from member where username='"+username+"'");
				if(str==null){
					int flag=cBean.comUp("insert into member(username,password,realname,sex,age,address,email,zy,bm) " +
							"values('"+username+"','"+password+"','"+realname+"','"+sex+"','"+age+"','"+address+"','"+email+"','"+zy+"','"+bm+"')");
					if(flag == Constant.SUCCESS){ 
						request.setAttribute("message", "Registration succeeded, please login!");
						request.getRequestDispatcher("login.jsp").forward(request, response); 
					}
					else { 
						request.setAttribute("message", "Operation failed!");
						request.getRequestDispatcher("reg.jsp").forward(request, response); 
					}
				}
				else{
					request.setAttribute("message", "The user name already exists!");
					request.getRequestDispatcher("reg.jsp").forward(request, response); 
				} 
			}
			
		}
		else if(method.equals("mupreg")){ //User modification of registration information
			String member=(String)session.getAttribute("member"); 
			String realname = request.getParameter("realname"); 
			String sex = request.getParameter("sex"); 
			String age = request.getParameter("age"); 
			String address = request.getParameter("address"); 
			String email = request.getParameter("email"); 
			String zy = request.getParameter("zy");
			String bm = request.getParameter("bm");
			int flag=cBean.comUp("update member set realname='"+realname+"',sex='"+sex+"',age='"+age+"'," +
					"address='"+address+"',email='"+email+"',zy='"+zy+"',bm='"+bm+"' where username='"+member+"'");
			if(flag == Constant.SUCCESS){ 
				request.setAttribute("message", "Operation succeeded!");
				request.getRequestDispatcher("member/info/index.jsp").forward(request, response); 
			}
			else { 
				request.setAttribute("message", "Operation failed!");
				request.getRequestDispatcher("member/info/index.jsp").forward(request, response); 
			}
		}
		else if(method.equals("mlogin")){//User login codes have comments 
			String username = request.getParameter("username"); 
			String password = request.getParameter("password");   
				String str=cBean.getString("select id from member where username='"+username+"' and  password='"+password+"'");
				if(str==null){
					request.setAttribute("message", "Login information error!");
					request.getRequestDispatcher("login.jsp").forward(request, response); 
				}
				else{
					session.setAttribute("member", username); 
					request.getRequestDispatcher("member/index.jsp").forward(request, response); 
				} 
		}
		else if(method.equals("lost")){ //Lost password
			String username = request.getParameter("username"); 
			String email = request.getParameter("email");   
			String str=cBean.getString("select id from member where username='"+username+"' and  email='"+email+"'");
			if(str==null){
				request.setAttribute("message", "Login information error!");
				request.getRequestDispatcher("login.jsp").forward(request, response); 
			}
			else{
				cBean.comUp("update member set password='111' where username='"+username+"'");
				request.setAttribute("message", "The new password is 111, please login and modify!");
				request.getRequestDispatcher("login.jsp").forward(request, response); 
			} 
		}
		else if(method.equals("memberexit")){ //Log out
			session.removeAttribute("member");
			request.getRequestDispatcher("index.jsp").forward(request, response);
		}
		else if(method.equals("muppwd")){//User change password
			String member=(String)session.getAttribute("member"); 
			String oldpwd = request.getParameter("oldpwd"); 
			String newpwd = request.getParameter("newpwd"); 
			String str=cBean.getString("select id from member where username='"+member+"' and  password='"+oldpwd+"'");
			if(str==null){
				request.setAttribute("message", "Original password information error!");
				request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response); 
			}
			else{
				int flag=cBean.comUp("update member set password='"+newpwd+"' where username='"+member+"'");
				if(flag == Constant.SUCCESS){ 
					request.setAttribute("message", "Operation succeeded!");
					request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response); 
				}
				else { 
					request.setAttribute("message", "Operation failed!");
					request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response); 
				}
			}
		}

The above is part of the function display. On the whole, the function of the system is very complete, and it is also related to the current hot topics. The interface design is simple and generous, the interaction is friendly, the database design is also very reasonable and the scale is moderate. It is more suitable for the relevant applications of graduation design and curriculum design.

Well, that's all for today. Let's praise, collect and comment. Let's start three times with one button. See you next time~~

Topics: Java Programming Back-end