首页 > 其他 > 详细

软件工程概论课后作业1

时间:2017-11-23 21:18:07      阅读:400      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/bangandwolf/p/7886675.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!