org.apache.jasper.JasperException: Exception in JSP: /ReplyOK.jsp:74: <%@ page import="java.sql.*" %>
5:
6: <%
7: int id = Integer.parseInt(request.getParameter("id"));
8: int rootId = Integer.parseInt(request.getParameter("rootid"));
9: String title = request.getParameter("title");
10: String cont = request.getParameter("cont");这个是peply.jsp代码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>Insert title here</title>
</head>
<body>
<form action="ReplyOK.jsp" method="post">
<input type="hidden" name="id" value=“<%=id %>”>
<input type="hidden" name="rootid" value="<%=rootId %>">
<table border="1">
<tr>
<td>
<input type="text" name="title" size="81">
</td>
</tr>
<tr>
<td>
<textarea cols="80" rows="12" name="cont"></textarea>
</td>
</tr>
<tr>
<td>
<input type="submit" value="提交">
</td>
</tr>
</table>
</form></body>
</html>这个是replyok.jsp的代码
<%@ page import="java.sql.*" %><%
int id = Integer.parseInt(request.getParameter("id"));
int rootId = Integer.parseInt(request.getParameter("rootid"));
String title = request.getParameter("title");
String cont = request.getParameter("cont");
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/bbs?user=root&password=root";
Connection conn = DriverManager.getConnection(url);String sql = "insert into article values (null, ?, ?, ?, ?, now(), 0)";
PreparedStatement pstmt = conn.prepareStatement(sql);
conn.setAutoCommit(false);pstmt.setInt(1, id);
pstmt.setInt(2, rootId);
pstmt.setString(3, title);
pstmt.setString(4, cont);
pstmt.executeUpdate(); Statement stmt = conn.createStatement();
stmt.executeUpdate("update article set isleaf = 1 where id= " + id); conn.commit();
conn.setAutoCommit(true);stmt.close();
pstmt.close();
conn.close();response.sendRedirect("showArticalTree.jsp");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>Insert title here</title>
</head>
<body>
<font color="red" size="7" >
OK!
</font>
</body>
</html>
正在学习Jsp上面的代码找了半天也不知道那里错了。
5:
6: <%
7: int id = Integer.parseInt(request.getParameter("id"));
8: int rootId = Integer.parseInt(request.getParameter("rootid"));
9: String title = request.getParameter("title");
10: String cont = request.getParameter("cont");这个是peply.jsp代码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>Insert title here</title>
</head>
<body>
<form action="ReplyOK.jsp" method="post">
<input type="hidden" name="id" value=“<%=id %>”>
<input type="hidden" name="rootid" value="<%=rootId %>">
<table border="1">
<tr>
<td>
<input type="text" name="title" size="81">
</td>
</tr>
<tr>
<td>
<textarea cols="80" rows="12" name="cont"></textarea>
</td>
</tr>
<tr>
<td>
<input type="submit" value="提交">
</td>
</tr>
</table>
</form></body>
</html>这个是replyok.jsp的代码
<%@ page import="java.sql.*" %><%
int id = Integer.parseInt(request.getParameter("id"));
int rootId = Integer.parseInt(request.getParameter("rootid"));
String title = request.getParameter("title");
String cont = request.getParameter("cont");
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/bbs?user=root&password=root";
Connection conn = DriverManager.getConnection(url);String sql = "insert into article values (null, ?, ?, ?, ?, now(), 0)";
PreparedStatement pstmt = conn.prepareStatement(sql);
conn.setAutoCommit(false);pstmt.setInt(1, id);
pstmt.setInt(2, rootId);
pstmt.setString(3, title);
pstmt.setString(4, cont);
pstmt.executeUpdate(); Statement stmt = conn.createStatement();
stmt.executeUpdate("update article set isleaf = 1 where id= " + id); conn.commit();
conn.setAutoCommit(true);stmt.close();
pstmt.close();
conn.close();response.sendRedirect("showArticalTree.jsp");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>Insert title here</title>
</head>
<body>
<font color="red" size="7" >
OK!
</font>
</body>
</html>
正在学习Jsp上面的代码找了半天也不知道那里错了。
jsp页面异常,你看一下ReplyOK.jsp页面第7行
int id = Integer.parseInt(request.getParameter("id"));
int rootId = Integer.parseInt(request.getParameter("rootid"));这就是6,7,8三行的,我看不出来那里错了,郁闷!
String cont = (String)request.getParameter("cont");
out.print("id"+request.getParameter("id"));
if(true) return;
打印出request.getParameter("id")是否获得值了.要是没值null怎么转化为int