zoukankan      html  css  js  c++  java
  • 软件工程概论之登录页面

    1、需要网站系统开发需要掌握的技术:服务器语言(例如 ASP、ASP.NET、ColdFusion 标记语言 (CFML)、JSP 和 PHP)生成支持动态数据库的 Web 应用程序。还需要有Tomcat的支持,还要数据库软件sql server的支持。

    2、本次课堂测试的源程序代码

    登录页面login.jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="GB18030"%>
    <!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=GB18030">
    <title>User</title>
    </head>
    <body>
    <form action="index.jsp" method="post">
    User Log<br>
    username<input type="text" name="name"/><br/>
    password<input type="password" name="psd">
    <input type="submit"name="submit"value="log" >
    </form>
    </body>
    </html>

    连接数据库页面index.jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="GB18030"%>
    <!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=GB18030">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    try{
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    String url="jdbc:sqlserver://localhost:1433; DatabaseName=Test";
    String username="sa";
    String password="*******";

    String user_name=request.getParameter("name");
    String user_pass=request.getParameter("psd");
    if(user_name==""||user_pass==""){
    out.print("name or password can't be null!");
    }else{

    Connection conn=DriverManager.getConnection(url, username, password);
    if(conn!=null){
    out.println("database success");

    Statement sm =conn.createStatement(); //创建Statement


    ResultSet rs=sm.executeQuery("select * from users where name='"+user_name+"'"+"and psd='"+user_pass+"'");
    if(rs.next()){
    response.sendRedirect("receive.jsp");
    }else{
    response.sendRedirect("error.jsp");
    }

    conn.close();
    }else{
    out.println("database fail");
    }
    }
    }catch(ClassNotFoundException e){
    e.printStackTrace();
    }
    %>
    </body>
    </html>

    登录成功 receive.jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!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>Insert title here</title>
    </head>
    <body>
    log success
    </body>
    </html>

    登录失败 error.jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!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>Insert title here</title>
    </head>
    <body>
    log fail ,please try again
    </body>
    </html>

    3、运行结果截图

     

    4、说明课堂测试未及时完成的原因

    寒假期间未按要求自学网站架构,导致今天课堂作业未能及时完成。

    5、列出你对这门课的希望和自己的目标,并具体列出你计划每周花多少时间在这门课上

    我希望关于软件工程的东西,然后把假期没有自学完的网页架构学完,

    我计划每周花10小时的时间在这门课上。

  • 相关阅读:
    函数式编程(三元运算、文件操作、函数、装饰器)
    开发基础(练习题)
    开发基础(字符串操作、元祖、元组、Hash、字典、集合、字符编码转换)
    开发基础(字符编码、列表操作)
    开发基础 (变量、数据类型、格式化输出、运算符、流程控制、while循环)
    [LeetCode] 127. 单词接龙
    [LeetCode] 126. 单词接龙 II
    [LeetCode] 122. 买卖股票的最佳时机 II
    [LeetCode] 124. 二叉树中的最大路径和
    [LeetCode] 125. 验证回文串
  • 原文地址:https://www.cnblogs.com/CkmIT/p/6485981.html
Copyright © 2011-2022 走看看