Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes Posting a jquery array to JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Posting a jquery array to JSP" Watch "Posting a jquery array to JSP" New topic
Author

Posting a jquery array to JSP

Abhilash Chander
Ranch Hand

Joined: Oct 18, 2009
Posts: 39
Hi All,

I am using jquery on my front end for a shopping cart application. After the cart is filled, on pressing save button the data will be saved into the database through a JSP.

Below I built the array from my cart items using jquery :




Then I post my array from jquery to JSP page 'SaveOrderDetails.jsp' as shown below :




Below are the parameter names I am getting on the JSP page :

orderDetails[2][gender],
orderDetails[2][price],
orderDetails[0][gender],
orderDetails[0][price],
orderDetails[2][name],
orderDetails[1][gender],
orderDetails[1][name],
orderDetails[1][price],
orderDetails[0][name]


As they are individual parameters, how can I fetch them as a two dimensional array instead of individual parameters. Because count of array is going to vary with number of items added to the cart.

My attempt to fetch the array on JSP page :



Hope you guys can take some time to help. Thanks for your help in Advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

First of all, Java code should be in a servlet, not a JSP.

Secondly, you might look into the commons beanutils project for help with converting complex params to beans and lists.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
wood burning stoves
 
subject: Posting a jquery array to JSP
 
Similar Threads
combo box issue in jsp
Complicated Array Problem
JSTL loop through jQuery array
DIV Tag Loading Behavior is Erratic
Drag and drop dynamic elements