Could anyone help me complete this code of ShoppingCart
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Aditya_Sharma
Posted On:   Wednesday, March 10, 2004 10:31 PM

public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { HttpSession ses = req.getSession(true); --code to print 5 columns of table -- while (r.next()) //r is resultset of database //Assume connection is established { out.println(r.getString(1)); . . out.println(r.getString(6)); out.println (" action= ") out.println (" out.println(" "); } // this helps to display say 4 books (depending on number /   More>>

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

{


HttpSession ses = req.getSession(true);


--code to print 5 columns of table --


while (r.next()) //r is resultset of database


//Assume connection is established


{


out.println(r.getString(1));


.


.


out.println(r.getString(6));


out.println ("



action= ")


out.println ("


out.println(" ");


} // this helps to display say 4 books (depending on number


// of records stored in database) with 4 check boxes to


// select them




//My problem: Please help me to pass the value of these


checkboxes to a session object.




---------------------------------------------------------


Kindly help me to add putValue of checkboxes to a session


object on click of Submit button
   <<Less

Re: Could anyone help me complete this code of ShoppingCart

Posted By:   vara_prakash  
Posted On:   Thursday, March 11, 2004 08:41 PM

ur check boxes return the values as an array of strings when you submit the form.


So use req.getParameterValues("full") to get the checkbox values. We can add these values to the session attribute by this way.



ArrayList cart = (ArrayList) session.getAttribute("cart");



if (cart==null){


cart = new ArrayList();


session.setAttribute("cart",cart);


}



String [] chkselected = req.getParameterValues("full");


if (chkselected !=null){



for (int i=0; i

cart.add(chkselected[i]);


}


}



I hope this would do for ur question. Let me know is this useful or not. I have done a cart application and I used the same concept.

About | Sitemap | Contact