zoukankan      html  css  js  c++  java
  • 第四周作业

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    
    
    <!DOCTYPE HTML >
    <html>
      <head>
       
        
        <title>登录界面</title>
        <!--
        <link rel="stylesheet" type="texts" href="styles.css">
        -->
        <style type="texts"> 
        .contentArea{450px;position:absolute;top:80px;left:250px;height:500px;} 
        <yle> 
      </head>
      
      <body  style="background:url(images/1.jpg)">
      <div class="contentArea">
      <p style="font-family:黑体;font-size:56;color:yellow"></p>
      登录<br/><br/><br/>
       <form action="dologin.jsp" name="myform" method="post" >
       用户名:<input type="text" name="uname"><br/><br/>
       密码:<input type="password" name="upwd"><br/>  <br/>
        验证码:<img src="number.jsp"/>
              <input type="text" name="code"/>
              <br/><br/>
       <input type="submit" value="登录"><br/><br/><br/><br/>
       <a href="register.jsp" >还没账户,进行注册?</a>
       </form>
       
       </div>
      </body >
    <ml>
    <%@ page contentType="image/jpeg" language="java" import="java.util.*,java.awt.*,java.awt.image.*,javax.imageio.*" pageEncoding="utf-8"%>
     
    <%
        //获取登录的用户名
        String name = request.getParameter("uname");
        //获取登录密码
        String pwd = request.getParameter("upwd");
        //判断
     
        if (name.equals("zs") && pwd.equals("123"))//判断字符串是否相等不是等号是eqyals
            //转发到ok页面
            request.getRequestDispatcher("ok.jsp").forward(request,response);
        else
            //转发到no页面
            request.getRequestDispatcher("login.jsp").forward(request,response);
    %>
     1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
     2 
     3 
     4 <!DOCTYPE HTML>
     5 <html>
     6   <head>
     7     
     8     <title>注册界面</title>
     9     
    10     <!--
    11     <link rel="stylesheet" type="texts" href="styles.css">
    12     -->
    13     <style type="texts"> 
    14     .contentArea{450px;position:absolute;top:150px;left:250px;height:500px;} 
    15     <yle> 
    16   </head>
    17   
    18   <body style="background:url(images/1.jpg)" >
    19   <div class="contentArea">
    20   注册个人信息:<br/><br/>
    21    <form action="dologin.jsp" name="myform" method="post" >
    22    用户名:<input type="text" name="uname"><br/><br/>
    23    密码:<input type="password" name="upwd"><br/><br/>
    24    
    25    性别:男孩<input type="radio" name="sex" checked="checked" value="男">
    26                女孩<input type="radio" name="sex" value="女" value="女"><br/><br/>
    27  
    28                
    29  爱好:<br/><br/>
    30 
    31    旱冰<input type="checkbox" name="hobby" value="旱冰">
    32    排球<input type="checkbox" name="hobby" value="排球">
    33    看书<input type="checkbox" name="hobby" value="看书">
    34    听音乐<input type="checkbox" name="hobby" value="听音乐">
    35    追剧<input type="checkbox" name="hobby" value="追剧">
    36    <br/>
    37    <br/>
    38 
    39    
    40    <select name="xl">
    41    <option value="幼儿园">幼儿园</option>
    42    <option value="小学">小学</option>
    43    <option value="初中">初中</option>
    44    <option value="高中">高中</option>
    45    <option value="本科">本科</option>
    46    <option value="硕士">硕士</option>
    47    <option value="博士">博士</option>   
    48    <lect>
    49    
    50    <br/>
    51       <br/>
    52          <br/>
    53             <br/>
    54    
    55    <input type="reset"> 
    56    <input type="submit" value="注册">
    57    </form>
    58    
    59    </div>
    60    
    61   </body>
    62 <ml>
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    
    <%
        request.setCharacterEncoding("utf-8");//防止乱码
        String name = request.getParameter("uname");//获取表单中名为uname的控件的value,返回的类型为字符串,如果要变成数值,需要类型转换 
        String pwd = request.getParameter("upwd");//此时的关键值要与之前界面的值相对应
        String sex = request.getParameter("sex");
        String xl = request.getParameter("xl");
    
        String[] hobbys = request.getParameterValues("hobby");//数组的取值,相同value的值为一类
    %>
    
    你注册的姓名是:<%=name%><br/>
    你注册的密码是:<%=pwd%><br/>
    你注册的性别是:<%=sex%><br/>
    你注册的学历是:<%=xl%><br/>
    你的爱好是:
    <%
        for (int i = 0; i < hobbys.length; i++)
            out.print(hobbys[i] + "&nbsp&nbsp&nbsp");
    %>
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</title>
    
        <!--
        <link rel="stylesheet" type="texts" href="styles.css">
        -->
        <style type="texts"> 
        .contentArea{450px;position:absolute;top:150px;left:250px;height:500px;} 
        <yle> 
      </head>
      
      <body  style="background:url(images/1.jpg)">
      <div class="contentArea">
      <h1 style="color: red">登录成功</h1>
       </div>
       
      </body>
    <ml>
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</title>
    
        <!--
        <link rel="stylesheet" type="texts" href="styles.css">
        -->
        <style type="texts"> 
        .contentArea{450px;position:absolute;top:150px;left:250px;height:500px;} 
        <yle> 
      </head>
      
      <body  style="background:url(images/1.jpg)">
      <div class="contentArea">
      <h1 style="color: red">登录成功</h1>
       </div>
       
      </body>
    <ml>
    <%@ page contentType="image/jpeg" language="java" import="java.util.*,java.awt.*,java.awt.image.*,javax.imageio.*" pageEncoding="utf-8"%>
     
    <%!
        Color getRandColor(int fc,int bc){
            Random random = new Random();
            if(fc > 255){
                fc = 255;
            }
            if(bc < 255){
                bc = 255;
            }
            int r = fc +random.nextInt(bc-fc);
            int g = fc +random.nextInt(bc-fc);
            int b = fc +random.nextInt(bc-fc);
     
     
            return new Color(r,g,b);
        }
    %>
     
    <%
        //设置页面不缓存
        response.setHeader("Pragma","no-cache");
        response.setHeader("Cache-Control","no-catch");
        response.setDateHeader("Expires",0);
     
        //在内存中创建图象
        int width = 60;
        int height = 20;
        BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
     
        //创建图象
        Graphics g = image.getGraphics();
        //生成随机对象
        Random random = new Random();
        //设置背景色
        g.setColor(getRandColor(200,250));
        g.fillRect(0,0,width,height);
        //设置字体
        g.setFont(new Font("Tines Nev Roman",Font.PLAIN,18));
        //随机产生干扰线
        g.setColor(getRandColor(160,200));
        for(int i = 0; i < 255; i++){
            int x = random.nextInt(width);
            int y = random.nextInt(height);
            int xl = random.nextInt(12);
            int yl = random.nextInt(12);
        }
        //随机产生认证码,4位数字
        String sRand = "";
        for(int i = 0; i < 4; i++){
            String rand = String.valueOf(random.nextInt(10));
            sRand  += rand;
            //将认证码显示到图象中
            g.setColor(new Color(20 + random.nextInt(110),20 + random.nextInt(110),20 + random.nextInt(110)));
            g.drawString(rand,13*i+6,16);
        }
        session.setAttribute("rCode",sRand);
        //图像生效
        g.dispose();
        //输出图像到页面
        ImageIO.write(image,"JPEG",response.getOutputStream());
        out.clear();
        out = pageContext.pushBody();
    %>
  • 相关阅读:
    实验三:UML 建模工具的安装与使用
    结对编程 第二阶段
    实验二:结对编程 第一阶段
    结对编程之github使用自己的仓库
    软工 实验一 Git代码版本管理
    第七次作业
    第5次作业
    第四次作业
    第三次作业
    第二次作业
  • 原文地址:https://www.cnblogs.com/WangYYY/p/14593784.html
Copyright © 2011-2022 走看看