zoukankan      html  css  js  c++  java
  • 留言板(application)

    用application制作简单留言板

    <%@ 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>留言板</title>
    </head>
    <body>
    
    <form action="55555.jsp" method="post">
    <table>
    <tr>
    <td>昵称:</td>
    <td><input type="text" name="name"/></td>
    </tr>
    <tr>
    <td>邮箱:</td>
    <td><input type="text" name="email"/></td>
    </tr>
    <tr>
    <td>留言内容:</td>
    </tr>
    </table>
    <table>
    <tr>
    <td><textarea  name="liuyan" rows="20" cols="60"></textarea></td>
    </tr>
    </table>
    
    
    <table>
    <tr>
    <td><input type="submit" value="提交"/></td>
    <td><input type="reset"/></td>
    </tr>
    
    
    </table>
    
    </form>
    
    
    
    
    
    </body>
    </html>

    处理界面:

    <%@ 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("name").getBytes("ISO-8859-1"),"UTF-8");
    String email=request.getParameter("email");
    String liuyan=new String(request.getParameter("liuyan").getBytes("ISO-8859-1"),"UTF-8");
    if(name==""||email==""||liuyan=="")
    {
        out.print("请把内容补充完整,5秒后跳转到留言界面");
        response.setHeader("refresh", "5;appliuyan.jsp");
        
        }
    else
    {
    String s="姓名:"+name+"<br>邮箱:"+email+"<br>留言内容:"+liuyan+"<br>";
    String message1=(String)application.getAttribute("message");
    if(message1==null)
    {
        application.setAttribute("message", s);
    }
    else
    {
        
        message1+=s;
        application.setAttribute("message", message1);
        
    }
    out.print("留言提交成功!");
    }
    
    %>
    
    <form action="66666.jsp">
    
    <table>
    <tr><td>查看其它留言</td></tr>
    <tr><td><input type="submit" value="查看"/></td></tr>
    
    
    </table>
    
    
    </form>
    
    
    
    
    
    </body>
    </html>
    <%@ 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 str=(String)application.getAttribute("message");
    out.print(str);
    
    %>
    <a href="appliuyan.jsp">继续留言</a>
    
    </body>
    </html>

    运行结果:

  • 相关阅读:
    知识图谱概述
    架构浅谈之 MVC
    windows下安装Levenshtein
    python安装pyahocorasick遇到error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools":
    解决pycharm中: OSError: [WinError 1455] 页面文件太小,无法完成操作 的问题
    win10下yolov5的cpu和gpu环境搭建
    使用neo4j工具导入知识图谱
    【2021.03.07】看论文神器知云文献翻译、百度翻译API申请、机器学习术语库
    【2021.03.06】智能家居之双控开关改单控开关+无线开关
    【2021.03.06】IMAP协议与POP3协议的对比、在Gmail中添加QQ邮箱IMAP同步
  • 原文地址:https://www.cnblogs.com/miss123/p/5631811.html
Copyright © 2011-2022 走看看