• 运用application编写简单留言板


    1、留言界面代码

    <%@ 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>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <form action="jieshou.jsp" method="post">
    <table wight="400" height="300" bord="1" bordercolor="FFFFFF" >
    <tr align="center" height="40"><td>留言簿</td></tr>
    <tr><td>
    <textarea rows="30" cols="80" name="liuyan"></textarea>
    </td></tr>
    <tr align="center" colspan="2"><td>
    <input type="submit" value="提交留言">
    </td></tr>
    </table>
    </form>
    </body>
    </html>
    

     2、接受留言界面代码

    <%@ 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>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    String name=new String(request.getParameter("liuyan").getBytes("ISO-8859-1"),"UTF-8");
    application.setAttribute("liuyan", name);
    
    %>
    留言成功!
    <a href="xianshi.jsp">点击查看留言</a>
    
    </body>
    </html>
    

     3、显示留言代码

    <%@page import="lianxi.zhuanhuan"%>
    <%@ 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>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    
    <%
    
    Object ly=application.getAttribute("liuyan");
    
    out.print(ly.toString());
    %>
    </body>
    </html>
    

     4、运行结果

  • 相关阅读:
    2019.6.20刷题统计
    36 线程 队列 守护线程 互斥锁 死锁 可重入锁 信号量
    35 守护进程 互斥锁 IPC 共享内存 的方式 生产者消费者模型
    34 进程 pid ppid 并发与并行,阻塞与非阻塞 join函数 process对象 孤儿进程与僵尸进程
    33 udp 域名 进程
    32 粘包 文件传输
    31 socket客户端. 服务器 异常 语法
    30 网络编程
    29 元类 异常
    26 封装 反射 常用内置函数
  • 原文地址:https://www.cnblogs.com/jakeasd/p/5631816.html
Copyright © 2020-2023  润新知