submit.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>留言板</title>
</head><body>
<h3>留言页面</h3>
<form action="messagepane.jsp" method="post" id="myform">
输入姓名:
<input type="text" name="name" value="">
</br>
输入留言标题:
<input type="text" name="title" value="" >
</br>
输入留言: 
<textarea name="mess" rows="10" cols="30" wrap="physical">
</textarea>
</br>
<input type="submit" name="submit" value="提交" >
</br></br>
</form><form action="messageshow.jsp" method="post" >
<input type="button" name="info" value="查看留言板" >
</form>
</body>
</html>

messagepane.jsp

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.util.*" errorPage="" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<%! 
 Vector v=new Vector();
synchronized void sendmess(String s){
  ServletContext application=getServletContext();
  v.add(s);
 application.setAttribute("mess",v);
}
%>
<%
 String name=request.getParameter("name");
 String title =request.getParameter("title");
 String mess=request.getParameter("mess");
 if(name==""){
  name="guest"+(int)Math.random()*10000;
 }
 if(title==""){
 title="无标题";
 }
 if(mess==""){
 title="无信息";
 }
 String str="Name:"+name+"Title:"+title+"Content:"+"<br>"+mess;
 sendmess(str);
 out.print("您的信息已提交");
%><a href="submit.jsp">返回</a>
</body>
</html>messageshow.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.util.*" errorPage="" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<%
 Vector v=(Vector)application.getAttribute("mess");
 for(int i=0;i<v.size();i++){
   String message=(String)v.elementAt(i);
    out.print(message+"<br/>");
 }
%>
</body>
</html>
点击查看留言板 没反应 错在哪?

解决方案 »

  1.   

    <input type="button" name="info" value="查看留言板" >
    改成
    <input type="submit" name="info" value="查看留言板" >
      

  2.   

    <input type="submit" name="info" value="查看留言板" >
      

  3.   

    button  你想提交  ??  换submit吧
      

  4.   

    button只是一个普通的按钮,照你这样写,除了能按而且按了没任何反应之外,基本上就没功能了,用form表单就用submit,一定想要用button,可以这样写<a href="messageshow.jsp"><input type = "button" name="info" value="查看留言板"/></a>,这样可以直接省掉form表单,还有一种,不用form表单,直接
    <input type = "button" name="info" value="查看留言板" onclick="Look()"/>,
    在上面的<head><script>function Look(){window.open("messageshow.jsp","_parent");}</script></head>,通过JS也可以的
      

  5.   

    把“查看留言板”的按钮 修改为submit提交信息
    或者 使用button类型时,调用onclick方法调用js代码进行信息提交
    form表单时需要提交  的
      

  6.   

    <input type="button" name="info" value="查看留言板" >还不如换成<a href="messageshow.jsp"/>
      

  7.   

    表单没提交 而且你的 查看留言板只是个button  没有点击事件 肯定不会有反应啊
      

  8.   

    <form action="messageshow.jsp" method="post" >
    <input type="button" name="info" value="查看留言板" >
    </form>没有submit,所以form的action没有执行。