pls check my code...

i am getting error with variables curprice and also with total...


i want to put the costs of all the products in the session objects and finally
calculate the totalcost and dispaly it..
pls help me

satish



import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;




public class cart extends HttpServlet
{



Connection con = null;
PreparedStatement pst = null;
ResultSet rs =
null;





public void init(ServletConfig sc) throws ServletException

{

try
{

Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");

con = DriverManager.getConnection("jdbc:db2:sample",
"satish", "london");

super.init(sc);

}

catch(Exception e) {e.getMessage() ; }

}







public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{




res.setContentType("text/html");
PrintWriter out = res.getWriter();

HttpSession session = req.getSession(true);

Object[] items = (Object []) session.getValue("cart.items");


out.println("<html> ");
out.println("<body bgcolor=899699>");
out.println("<H3>you currently have the following
items in your cart:</H3><br>");
out.println("<form> ");

out.println("<table>");

if(items!=null)
{

for (int i = 0 ; i < items.length
; i++ )
{

try
{

String str1 =
(String) items[ i ] ;

pst = con.prepareStatement("select
* from ITEMTAB where itmname = ? " );


pst.setString(1,str1)
;
rs = pst.executeQuery(
);




while(rs.next())
{
out.println("<tr>
");

out.println("<td> ");



out.println( "The Price of " + " " + str1 + " is "
+ " " + rs.getString("price"));



out.println("</td> ");
out.println("</tr>
");


out.println("</table>
");

out.println("<br>");


String
curprice = rs.getString("price") ;

session.putValue("total.cost",
curprice+curprice );

}


String totprice = (Object)
session.getValue("total.cost");

Object total = (Object) curprice
+ totprice ;



session.putValue("total.cost",
total );






}

catch(Exception e) { e.getMessage()
; }

}



out.println("<table border
= 1 cellpadding = 2 cellspacing = 3>");
out.println("<tr>
");
out.println("<td>
");




out.println("The Total Cost of all the Products in the Cart is : " +
total );

out.println("</td>
");
out.println("</tr>
");
out.println("</table>
");






out.println("</form>
");



}



else
{
out.println("There are no items in the session
value for cart.items" );

}


out.println("</body>");

out.println("</html> ");

}


}