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>

    运行结果:

  • 相关阅读:
    HUST 1584 摆放餐桌
    HUST 1585 排队
    HUST 1583 长度单位
    树状数组 poj2352 Stars
    Visual Studio2013应用笔记---WinForm事件中的Object sender和EventArgs e参数
    倒置输入的数 Exercise07_02
    指定等级 Exercise07_01
    检测密码 Exercise06_18
    一年的天数 Exercise06_16
    数列求和 Exercise06_13
  • 原文地址:https://www.cnblogs.com/miss123/p/5631811.html
Copyright © 2011-2022 走看看