jsp空指针问题,求大神
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table>
<tr>
<td>商品名称</td>
<td>商品单价</td>
<td>购买</td>
</tr>
<form action= "NewFile1.jsp" method= "post">
<tr>
<td>手机</td>
<td>2000</td>
<td><input type= "submit" name= "buy" value="购买"/>
</tr>
<input type= "hidden" name="goodname" value="手机"/>
<input type="hidden" name= "price" value= "2000"/>
</form>
<form action= "NewFile1.jsp" method= "post">
<tr>
<td>电视</td>
<td>5000</td>
<td><input type= "submit" name= "buy" value="购买"/>
</tr>
<input type= "hidden" name="goodname" value="电视"/>
<input type="hidden" name= "price" value= "5000"/>
</form>
<form action= "NewFile1.jsp" method= "post">
<tr>
<td>洗衣机</td>
<td>3000</td>
<td><input type= "submit" name= "buy" value="购买"/>
</tr>
<input type= "hidden" name="goodname" value="洗衣机"/>
<input type="hidden" name= "price" value= "3000"/>
</form>
<form action= "NewFile1.jsp" method= "post">
<tr>
<td>空调</td>
<td>4000</td>
<td><input type= "submit" name= "buy" value="购买"/>
</tr>
<input type= "hidden" name="goodname" value="空调"/>
<input type="hidden" name= "price" value= "4000"/>
</form>
<table/>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="cc.Good"%>
<%@ page import="java.util.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%request.setCharacterEncoding("utf-8");
String goodname=request.getParameter("goodname");
String price=request.getParameter("price");
Good good =new Good();
good.setGoodname(goodname);
good.setPrice(price);
ArrayList <Good> a=null;
HttpSession sess = request.getSession();
if(session.getAttribute("good")==null){
a=new ArrayList<Good>();
}else{
a=(ArrayList<Good>)session.getAttribute("good");
}
a.add(good);
sess.setAttribute("good", a);
response.sendRedirect("NewFile2.jsp");
%>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="cc.Good"%>
<%@ page import="java.util.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table>
<tr>
<td>商品名称</td>
<td>商品单价</td>
<td>数量</td>
</tr>
<table/>
<%! ArrayList<Good> arry;
Good good[];
int price;%>
<%
HttpSession ses = request.getSession();
arry=(ArrayList<Good>)ses.getAttribute("good");
if(arry!=null){
for(int i=0;i<arry.size();i++){
good[i]=arry.get(i);
price+=Integer.parseInt(good[i].getPrice());
out.println(good[i].getGoodname());
out.println(good[i].getPrice());
out.println("<br/>");
}
out.println("商品总价"+price);
}
%>
<%=arry %>
</body>
</html>
求大神, good[i]=arry.get(i);为什么这里会报空指针异常啊,该怎么解决