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>
    

      

  • 相关阅读:
    简单的Vue示例
    Vue开发环境搭建基本操作
    2020CentOS官网下载镜像方法
    while((ch=getchar()) !=EOF && ch != ' ');语句作用
    Mac 下使用svn
    用树形结构递归渲染权限列表
    .net core中使用jwt进行认证
    C#中异步多线程的实现方式
    redis-避免生产环境使用keys命令
    让visual studio总是以管理员身份启动
  • 原文地址:https://www.cnblogs.com/langlove/p/3729814.html
Copyright © 2011-2022 走看看