新手请教,自己制作的jsp+mysql留言板的添加留言页面老是出错
这是代码,麻烦大家看一下<%@page contentType="text/html;charset=gb2312" %>>
<%@page import="java.sql.*" %>
<HTML>
<HEAD>
<TITLE>所有用户留言</TITLE>
</HEAD>
<BODY>
<p align="center">所有访客留言</p>
<hr>
<%
try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/message";
Connection conn= DriverManager.getConnection(url,"root","12qazwsx");
Statement stmt=conn.createStatement();
ResultSet result=stmt.executeQuery("select count(*) from message");
int message_count=0;
if(result.next())
{
message_count=result.getInt(1);
result.close();
}
if(message_count>0)
{
result=stmt.executeQuery("select*from message");
while(result.next())
String title=result.getString("title");
String name=result.getString("name");
String content=result.getString("content");
%>
<TABLE width="100%" align="center" border=0 >
<tr><td bgcolor="#88a6dd"><font size=2>主题:</font></td>
<td colspan=3><%=title%></td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>留言人:</font></td>
<td colspan=3><%=name%></td>
</tr>
<tr><td align="center">
<%
out.println("("+message_count+")");
%>
</td>
<td colspan=3><%=result.getString("content")%>
</td></tr>
</table>
<p align="center"><a href="../message/index.html">我要留言</a></p>
<%
try
{
result.close();
stmt.close();
conn.close();
}catch(ClassNotFoundException cnfe){
out.print(cnfe);
}catch(SQLException sqle){
out.print(sqle);
}catch(Exception e){
out.print(e);
}
%>
</body>
</html>
tomcat的报错
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 28 in the generated java file
Syntax error, insert "}" to complete ClassBody
An error occurred at line: 28 in the jsp file: /viewmessage.jsp
Syntax error, insert "AssignmentOperator Expression" to complete Assignment
25: {
26: result=stmt.executeQuery("select*from message");
27: while(result.next())
28: String title=result.getString("title");
29: String name=result.getString("name");
30: String content=result.getString("content");
31: %>
An error occurred at line: 28 in the jsp file: /viewmessage.jsp
Syntax error, insert ";" to complete Statement
25: {
26: result=stmt.executeQuery("select*from message");
27: while(result.next())
28: String title=result.getString("title");
29: String name=result.getString("name");
30: String content=result.getString("content");
31: %>
An error occurred at line: 28 in the jsp file: /viewmessage.jsp
String cannot be resolved to a variable
25: {
26: result=stmt.executeQuery("select*from message");
27: while(result.next())
28: String title=result.getString("title");
29: String name=result.getString("name");
30: String content=result.getString("content");
31: %>
An error occurred at line: 28 in the jsp file: /viewmessage.jsp
title cannot be resolved to a variable
25: {
26: result=stmt.executeQuery("select*from message");
27: while(result.next())
28: String title=result.getString("title");
29: String name=result.getString("name");
30: String content=result.getString("content");
31: %>
An error occurred at line: 34 in the jsp file: /viewmessage.jsp
title cannot be resolved to a variable
31: %>
32: <TABLE width="100%" align="center" border=0 >
33: <tr><td bgcolor="#88a6dd"><font size=2>主题:</font></td>
34: <td colspan=3><%=title%></td></tr>
35: <tr><td bgcolor="#88a6dd"><font size=2>留言人:</font></td>
36: <td colspan=3><%=name%></td>
37: </tr>
An error occurred at line: 130 in the generated java file
Syntax error, insert "else Statement" to complete IfStatement
An error occurred at line: 130 in the generated java file
Syntax error, insert "}" to complete Block
An error occurred at line: 140 in the generated java file
Syntax error, insert "Finally" to complete TryStatement
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) --------------------编程问答-------------------- viewmessage.jsp
中少了一个“}”
补充:Java , Web 开发