• 软件工程概论课后作业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.每周花多少时间在这门课上:

    每天大约两小时左右

     
     
     
  • 相关阅读:
    中移动ipv6-老毛子固件获取ipv6设置
    win7-win10 禁用IPV6临时地址
    辅助调用函数【call,apply,bind】
    Unraid修改docker镜像地址&默认启动
    docker基本入门知识-小白向
    [不止于代码]Unraid基本使用速记
    Dockerfile文件说明
    Git之pull,fetch差别
    代码片段添加智能提示,打造一款人见人爱的ORM框架
    新定义三层,指挥官模式
  • 原文地址:https://www.cnblogs.com/bangandwolf/p/7886675.html
Copyright © 2020-2023  润新知