软件工程课堂测验及课后作业

1.网站系统开发需要掌握的技术:

  网站开发技术需要掌握HTMLcss、JSP等语言HTML(超文本标记语言)是网页的核心,学好HTML是成为Web开发人员的基本条件JavaScript可以有效的使网页增加特色,css语言可以改善网页外观。了解web服务器并挑选一门服务器脚本语言进行学习。学习数据库原理以及SQL语法等等。

2.课堂测验登录界面的源程序代码和截图:

源代码:

Login.jsp

<%@ page contentType="text/html; charset=UTF-8"%>
<html>
    <head>
        <title>用户登录</title>
    </head>
    <body>
        <h2 align="center">用户登录</h2>
        <form name="form1" action="loginprocess.jsp" method="post">
                 <table align="center" border="0">
                    <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="submit" value="登录"></td>
                    </tr>
                </table>                     
        </form>
    </body>
</html>

 loginprocess.jsp

<%@ page language="java" import="java.sql.*" 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 http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录中</title>
</head>
<body>
<%
    request.setCharacterEncoding("UTF-8");
    String driverStr = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    String connStr = "jdbc:sqlserver://localhost:1433;DatabaseName=login";
    String dbusername = "sa";
    String dbpassword = "160340";
     
    Connection conn = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;    
    Class.forName(driverStr);
    conn = DriverManager.getConnection(connStr, dbusername, dbpassword);
    String sql = "select * from denglu where [username]=? and [password]=?";//定义一个查询语句
    stmt = conn.prepareStatement(sql);
    
    String user=request.getParameter("username");
    String pass=request.getParameter("password");//取出login.jsp的值
    stmt.setString(1, user);
    stmt.setString(2, pass);
    if(user.equals(""))
    {    
        out.print("<script language='javaScript'> alert('请输入用户名');</script>");
        response.setHeader("refresh", "0;url=login.jsp");
    }
    else if(pass.equals(""))
    {
        out.print("<script language='javaScript'> alert('密码为空');</script>");
        response.setHeader("refresh", "0;url=login.jsp");
    }

    rs = stmt.executeQuery();
    if(rs.next())
        response.sendRedirect("loginsucceed.jsp");
    else 
    {
        out.print("<script language='javaScript'> alert('账号或密码错误');</script>");
        response.setHeader("refresh", "0;url=login.jsp");
    }
    rs.close();
    stmt.close();
    conn.close();
%>
</body>
</html>

 

 loginsucceed.jsp

<%@ page language="java" contentType="text/html; charset=gb2312"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录成功</title>
</head>
<body>
<h1>登录成功!</h1>
</body>
</html>

 

 login_fail.jsp

<%@ page language="java" contentType="text/html; charset=gb2312"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>登录失败</title>
</head>
<body>
<h1>登录失败!</h1>
</body>
</html>

 

  运行结果截图:

               正确账号和密码:

              错误账号和密码:

                空账号和密码:

3.课堂测试未按时完成是因为安装sql server 2014 时出现问题,配置管理器丢失,导致无法配置,不能将eclipse与数据库相连接。

4.因为本学期课程比较多,预计自己在完成老师任务和作业的情况下用八个小时学习相关内容。

posted @ 2017-02-28 22:19  暖心系  阅读(195)  评论(0编辑  收藏  举报