zoukankan      html  css  js  c++  java
  • java web 程序---留言板

    思路:一个form表单,用户提交留言

    一个页面显示留言内容。用到Vector来存取信息并显示

    cas.jsp

    <body>
        <form action="fei.jsp">
     		 留言人: <input type="text" name="name"/><br/>
        	标题:<input type="text" name="title"/><br/>
        	留言内容:<br/>
        	<textarea rows="6" cols="40" name="message"></textarea>
        	<br/>
        	<input type="submit" value="提交"/>
        </form>
      </body>
    

      fei.jsp

     <body>
        <%
        	String name=request.getParameter("name");
        	String a=new String(name.getBytes("ISO-8859-1"),"gb2312");
    		String title=request.getParameter("title");
    		String b=new String(title.getBytes("ISO-8859-1"),"gb2312");
    		String message=request.getParameter("message");
    		String c=new String(message.getBytes("ISO-8859-1"),"gb2312");
    		Vector v=(Vector)application.getAttribute("v");    
        		if(v==null){
        			v=new Vector();
        	
        	}
        		String time=(new Date()).toLocaleString();
        		String s=a+"#"+b+"#"+c+"#"+time;//这里的”#“符号不能多写,否则会多出一列来
         
         		v.add(s);
         		application.setAttribute("v",v);
         		if(name==null||name.equals("")){
         		name="guess"+(int)(Math.random()*1000);
         	}
         		out.print("<table border='1'>");
         		out.print("<tr><th>留言人</th><th>标题</th><th>留言内容</th><th>留言时间</th></tr>");
         		for(int i=0;i<v.size();i++){
         			out.print("<tr>");
         			String st=(String)v.elementAt(i);
         				String ss[]=	st.split("#");
         					for(int j=0;j<ss.length;j++){
         					
         						out.print("<td>"+ss[j]+"</td>");
         							
         					}
         					out.print("</tr>");
         		}
         %>
      </body>
    

      

  • 相关阅读:
    在Objective-C声明Block的几种方式
    属性初始化
    OC协议
    堆排序的OC实现
    iOS 应用性能测试的相关方法、工具及技巧
    墙裂推荐 iOS 资源大全
    剖析@weakify 和 @strongify
    iOS开发大神必备的Xcode插件
    聊聊 KVC 和 KVO 的高阶应用
    TableView的优化
  • 原文地址:https://www.cnblogs.com/langlove/p/3729814.html
Copyright © 2011-2022 走看看