jsp异常
请高手指教!
jsp老是异常
jsp如下:
<%@ page contentType="text/html; charset=gbk" language="java"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="javabean.*"%>
<%!//每页显示的记录数
int pageSize = 8;
int showPage = 1;
%>
<%
request.setCharacterEncoding("gbk");
String yuanxi = session.getAttribute("yuanxi").toString();
String nianji = session.getAttribute("nianji").toString();
String zhuanye = session.getAttribute("zhuanye").toString();
String xuenian = session.getAttribute("xuenian").toString();
String xueqi = session.getAttribute("xueqi").toString();
String kecheng = session.getAttribute("kecheng").toString();
Object ob = session.getAttribute("teacher");
String teacher = ob.toString();
String strPage = null;
String hang1 = request.getParameter("hangshu");
if (hang1 != null) {
// byte[] b = hang1.getBytes("iso-8859-1");
// hang1 = new String(b);
int hang = Integer.parseInt(hang1);
System.out.println(hang);
if (hang > 0) {
System.out.println(hang + "yyh");
%>
<jsp:useBean id="selectCourse" scope="session" class="javabean.SeleCourse"/>
<%
int[] cundefen = new int[hang];
String[] cundehao = new String[hang];
for (int i = 0; i < hang; i++) {
String ss = request.getParameter("fen" + i);
System.out.print(ss);
cundefen[i] = Integer.parseInt(ss);
cundehao[i] = request.getParameter("hao" + i);
}
selectCourse.setGrade(cundefen);
selectCourse.setCnumber(cundehao);
int[] j = selectCourse.UpdataGrade(kecheng, xueqi, xuenian);
System.out.println(j[0] + "aaa");
}
}
strPage = request.getParameter("showPage");
if (strPage == null) {
showPage = 1;
} else {
try {
showPage = Integer.parseInt(strPage);
} catch (NumberFormatException e) {
showPage = 1;
}
if (showPage < 1) {
showPage = 1;
}
}%>
<jsp:useBean id="pages" scope="page" class="javabean.splitPage" />
<%
pages.initialize(kecheng, xueqi, xuenian, zhuanye, yuanxi, teacher, pageSize, showPage);
ResultSet rs = pages.getPage();
rs.last();
int xianshi = rs.getRow();
rs.beforeFirst();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>分页显示</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div align=center>
<form action="chulichengji.jsp" method="post" target="_self" name="form2">
<table border="2" >
<tr>
<th>学号</th>
<th>姓名</th>
<th>分数</th>
</tr>
<%
for (int i = 0; i < xianshi; i++) {
rs.next();
%>
<tr>
<td><input type="text" name="<%="hao" + i%>" value="<%=rs.getString(1)%>" style="border:0;" /></td>
<td><%=rs.getString(2)%></td>
<td><input type="text" name="<%="fen" + i%>" value="<%=rs.getString(3)%>" style="border:0;" size="3"/></td>
</tr>
<%
}%>
</table>
共<font color=red><%=pages.getRowCount()%></font>条 <%=pageSize%>条/页
第<font color=red><%=showPage%></font>页/共<font color=red><%=pages.getPageCount()%></font>页
<% if (showPage != 1) {%>
<a href="chulichengji.jsp?showPage=1&hangshu=<%=xianshi%>" target="_self">[首
页]</a><%} else {%>[
页]<%}%> <%
//判断"上一页"链接是否要显示
if (showPage > 1) {
%> <a href="chulichengji.jsp?showPage=<%=showPage - 1%>&hangshu=<%=xianshi%>" target="_self">[上一页]</a> <%
} else {
%> [上一页] <% }
//判断"下一页"链接是否要显示
if (showPage < pages.getPageCount()) {
%> <a href="chulichengji.jsp?showPage=<%=showPage + 1%>&hangshu=<%=xianshi%>" target="_self">[下一页]</a> <%
} else {
%> [下一页] <% }
%>
<%if (showPage != pages.getPageCount()) {%>
<a
href="chulichengji.jsp?showPage=<%=pages.getPageCount()%>&hangshu=<%=xianshi%>" target="_self">[尾页]</a><%} else {%>[尾页]<%}%> 转到 <select name="showPage">
<%
for (int x = 1; x <= pages.getPageCount(); x++) {
%>
<option value="<%=x%>"
<%if (showPage == x) {
out.println("selected");
}%>><%=x%></option>
<%
}
%>
</select> 页 <input type="submit" name="go" value="提交" /></form>
</br><a href="chengjichaxun.jsp">返回</a> <a href="exit.jsp">退出系统</a>
<%
//关闭数据库连接
pages.Close();
pages.CloseConnecting();
%>
</div>
</body>
</html>
异常信息如下
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /chulichengji.jsp at line 42
39: for (int i = 0; i < hang; i++) {
40: String ss = request.getParameter("fen" + i);
41: System.out.print(ss);
42: cundefen[i] = Integer.parseInt(ss);
43: cundehao[i] = request.getParameter("hao" + i);
44: }
45: selectCourse.setGrade(cundefen);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Integer.java:417)
java.lang.Integer.parseInt(Integer.java:499)
org.apache.jsp.chulichengji_jsp._jspService(chulichengji_jsp.java:109)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
[解决办法]
42: cundefen[i] = Integer.parseInt(ss);
改为cundefen[i]=(int) Double.parseDouble(ss);
[解决办法]