File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Arrays in JSP form

 
Juhan Voolaid
Ranch Hand
Posts: 179
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am looking for the best solution to my problem and I describe it with a small example.

I have a ArrayList of products:


And that ArrayList of products is sent to a form, where user can review the product list and change the quantity of each individual product. After submitting it, servlet takes over then.

Now the question is: how to construct that form, so that it is comfortable to access the data from servlet?


Here is one solution:


And in this case it is not so easy to get the parameters in servlet. When the data is like so:
id_1=2; price_1=200; quantity_1=3;
id_2=16; price_2=300; quantity_2=1;
id_3=7; price_3=50; quantity_3=5;
....
So in servlet I have to check when the ${loopCount.count} stopped by compareing if request.getParameter("id_3")==null

But I am woundering, if there is more better solution for that type of problem. In my mind I am thinking of presenting and getting back arrays from html form somehow, but I don't know if it is possible.


Thanx.
 
Juhan Voolaid
Ranch Hand
Posts: 179
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And another thing (even though it gous to struts subject): how to make a ActionForm to validate this generated form, because I don't know how many "quantity_x" parameters there will be?
 
Stefan Evans
Bartender
Posts: 1640
9
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic