java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:415)
at java.lang.Integer.parseInt(Integer.java:497)
at _liuyuanban__jsp._jspService(/liuyuanban.jsp:31)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:311)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:221)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
at java.lang.Thread.run(Thread.java:595)
下面是自己写的代码:
<%@ page contentType="text/html;charset=gb2312" language="java" import="java.sql.*,java.io.*,java.util.*" %>
<html>
<head>
<title>简易留言板</title>
</head>
<body>
<center>
<script language=javascript>
<!--
function tijiao()
{
if(checkbox.titletext.value=="")
{
window.alert("你还没有写你要发表的留言的主题");
checkbox.titletext.focus();
return;
}
else if(checkbox.textarea.value=="")
{
window.alert("你还没有写任何留言");
checkbox.textarea.focus();
return;
}
else
{
<%
int photoid=Integer.parseInt(request.getParameter("face"));
String title=request.getParameter("titletext");
String nr=request.getParameter("textarea");
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liuyuangban";
String user="sa";
String pw="";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn= DriverManager.getConnection(url,user,pw);
Statement stmt=conn.createStatement();
String sql="insert into liuyuan(title,text,photoid) values(\'"+title+"\',\'"+nr+"\',"+photoid+")";
stmt.executeUpdate(sql);
out.print("留言成功");
%>
}
}
-->
</script>
<form action="liulan.jsp" method="post" name=checkbox >
<table width="800" border="0" align="left" bgcolor="#fedf87" cellspacing="0" cellpadding="0" >
<tr>
<td width="100%" align="center" ><font size="5" color="#FFFFFF"><b><u>填写留言</u></b></font></td>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#FCFCFC">发表主题</td>
</tr>
<tr>
<td width="100%" bgcolor="#FCFCFC"><input name="titletext" type="text" size="60"></td>
</tr >
<tr><td width="100%" bgcolor="#FCFCFC">内容:</td>
</tr>
<tr><td width="100%" bgcolor="#FCFCFC" align=left><textarea name="textarea" cols=60 rows=10></textarea></td>
</tr>
<tr>
<td width="100%" bgcolor="#FCFCFC">
<% for(int i=1;i<=10;i++){%>
<input name="face" type="radio" value=<%=i%>> <img src="image/<%=i%>.gif" >
<%}%>
</td>
</tr>
<tr><td ><input type=button value="提交" onclick=tijiao();> <input name="reset" type="reset" value="取消"></td></tr>
</table>
</form>
</center>
</body>
</html>