日期:2014-05-17  浏览次数:20770 次

jsp找不到错误
messagebox.jsp

<%@ page contentType="text/html;charset=gb2312" import="java.util.*" language="java" %>
<% request.getCharacterEncoding("gbk") %>

<%  
if(session.isNew()){
session.setAttribute("show",0);
}
                                                     
int k=0,j=1;
try{
k=Integer.parseInt(application.getAttribute("count").toString());
}catch(Exception e){}

class Box{
String name;
String title;
String content;
Box(String name,String title,String content){
this.name=name;
this.title=title;
this.content=content;
}
}
String askname,asktitle,askcontent;
if(j<k) j=k;


Enumeration info=request.getParameterNames();
if(info.hasMoreElements()){
askname=request.getParameter("name").toString();
asktitle=request.getParameter("title").toString();
askcontent=request.getParameter("content").toString();
Box box = new Box(askname,asktitle,askcontent);
application.setAttribute("box"+j,box);
j++;
application.setAttribute("count",new Integer(j));

}



%>


<html>
<head><title>留言板</title></head>

<body align= center>
<h2 align =center>留言板</h2>
<form method="get" >
<table align=center>
姓名:<input type="text" name="name" ><br><br>
标题:<input type="text" name="title" ><br><br>
留言:<textarea name="content" cols=30 rows=6></textarea><br><br>

&nbsp&nbsp&nbsp&nbsp&nbsp<input type=submit value="提交">
&nbsp&nbsp<input type=button name="view" value="查看留言" onclick="location.href='view.jsp';">
&nbsp&nbsp<input type=reset name="reset" value="重置">
</table>
</form>
<% if(session.getAttribute("show").equals(1){
int h;
String ss;
int i=1;
out.println("<hr/><h2 align=center>查看留言</h2>");
out.pritnln("<table align=center border='1'>");
Enumeration message = application.getAttributeNames();
if(message.hasMoreElements()){
for(h=1;h<j;h++){
ss="box"+h;
try{
Box xx = (Box) application.getAttribute(ss);
if(!xx.name.equals("")||!xx.title.equals("")||!xx.content.equals("")){
out.println("<tr><td>第"+i+"位</td><td>姓名:"+xx.name+"</td><td>标题:"+xx.title+"</td><td>内容:"+xx.content+"</td></tr>");
i++;
}
}catch(Exception e){}
}
out.println("</table>");
session.setAttribute("show",0);
}
}
%>

</body>

</html>


view.jsp

<%@ page contentType="text/html;charset=gbk" %>
<% request.getCharacterEncoding("gbk") %>
<% session.setAttribute("show",1);
   response.sendRedirect("messagebox.jsp");