软件工程概论课后作业1
Posted peanut
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了软件工程概论课后作业1相关的知识,希望对你有一定的参考价值。
1.网站系统开发需要掌握的技术:
JSP、Servlet、JDBC、JavaBean、UML统一建模语言的UML图、javascript、XML、html、css语言。
2.源代码:
addInut.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> <title>用户添加页面</title> </head> <body> <%=request.getAttribute("error") %> <form action="add.jsp" method="get"> <table align="center" border="1" width="500"> <tr> <td>用户名称 : </td> <td> <input type="text" name="username" /> </td> </tr> <tr> <td>用户密码:</td> <td> <input type="password" name="password" /> </td> </tr> <tr> <td>用户昵称:</td> <td> <input type="text" name="nickname" /> </td> </tr> <tr align="center"> <td colspan="2"> <input type="submit" value="提交" /> <input type="reset" value="重置" /> </td> </tr> </table> </form> </body> </html>
login1
<%@ 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> <title>登录界面</title> </head> <body style="background-image:url(\'../image/back.jpg\');"> <%//=request.getAttribute("error") %> <center style="color:black ; font-family:宋体;font-size:16px">登录</center> <form action="login2.jsp" method="get"> <table align="center" border="1" width="500"> <tr> <td>用户名称 : </td> <td> <input type="text" name="username" /> </td> </tr> <tr> <td>用户密码:</td> <td> <input type="password" name="password" /> </td> </tr> <tr> <tr align="center"> <td colspan="2"> <input type="submit" value="登录" /> <a href="addInput.jsp">点击注册</a><br> </td> </tr> </table> <br> <center> <%=request.getAttribute("error") %></center> </form> </body> </html>
login2
<%@page import="com.jaovo.msg.Util.UserException"%> <%@page import="com.jaovo.msg.dao.UserDaoImpl"%> <%@page import="com.jaovo.msg.model.User"%> <%@page import="java.sql.Connection"%> <%@page import="java.sql.PreparedStatement"%> <%@page import="java.sql.ResultSet"%> <%@page import="com.jaovo.msg.Util.DBUtil"%> <%@ 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> <% //接收客户端传递过来的参数 String username = request.getParameter("username"); String password = request.getParameter("password"); if(username == null || "".equals(username.trim())){ request.setAttribute("error", "用户名不能为空"); %> <jsp:forward page="login1.jsp"></jsp:forward> <% } User user = new User(); user.setUsername(username); UserDaoImpl userDao = new UserDaoImpl(); Connection connection=DBUtil.getConnection(); PreparedStatement preparedStatement = null; ResultSet resultSet = null; String sql = "select * from t_user where username = ?"; preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, user.getUsername()); resultSet = preparedStatement.executeQuery(); if(resultSet.next()) { if(resultSet.getString("password").equals(password) ){ //response.sendRedirect("loginsuccess.jsp"); out.print("<script language=\'javaScript\'> alert(\'登陆成功\');</script>"); response.setHeader("refresh", "0;url=login.jsp"); } else{ out.print("<script language=\'javaScript\'> alert(\'密码错误\');</script>"); response.setHeader("refresh", "0;url=login.jsp"); } } else { out.print("<script language=\'javaScript\'> alert(\'账号错误——else\');</script>"); response.setHeader("refresh", "0;url=login.jsp"); } %> </html>
3.实验截图
4.对这门课的希望和自己的目标:
希望可以好好学习,争取不挂科
5.每周花多少时间在这门课上:
每天大约两小时左右
以上是关于软件工程概论课后作业1的主要内容,如果未能解决你的问题,请参考以下文章