How to attach parameters in JSP based form

Ive been having this problem for the past couple of months and if you help I would really appreciate it. Im not sure if its a general JSP Ques or its simple HTML.

Im using the <c:forEach> to loop around products from a database then displaying them (incl an "Add to basket" button per each product) as an html form using jsp. Each row display is obviously associated with a product ID (primary key from the database). Now what I want to happen is: If someone clicks on add to basket on a certain produck, I need that product ID # to be carried over to the next page. This is obviously easy if the initial output was just static but here its dynamic. Here is a small shot of what Im saying:

The code

=====================================================

<table>

<tr>

<td>Product ID</td>

<td>Product Name</td>

<td>Price</td>

<td>Quantity</td>

<td>Add to Basket</td>

</tr>

<c:forEach var="row" items="${databaseResult.rows}">

<tr>

<td>${row.dbProductId}</td>

<td>${row.dbProductNm}</td>

<td>${row.dbPrice}</td>

<td><input type="text" name="formQuantity" value="Show Full Details"/></td>

<td><input type="submit" name="formSubmit" value="Add to Basket"/></td>

</tr>

</c:forEach>

</table>

=====================================================

The above is the code. When I have 10 products displayed, the moment I click on the 6th "Add to Basket" link, all parameters "formQuantity" are carried over yet I only want one to be carried. Ive tried using <input type= "hidden" but the same case happens again.

PLEASE HELP>

[2242 byte] By [piasonpa] at [2007-10-2 16:54:27]
# 1
you can try <a href=URL>丆URL contained a parameter of the product ID
yinbinfeng0451a at 2007-7-13 18:06:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hie.Im not sure where I infringed Suns code of conduct. Please help so I know
piasonpa at 2007-7-13 18:06:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Thanks a lot mate. Let me try that one. Ignore the previous I sent. My confusion
piasonpa at 2007-7-13 18:06:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Hie. Looks like the value parameter in <c:url only takes urls only and I cannot put a parameter value. Thanks for trying to help.ANYONE WHO ELSE WHO CAN TRY TO HELP ME OUT PLEASE>
piasonpa at 2007-7-13 18:06:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

><c:url only takes urls only and I cannot put a parameter value ?

You are wrong sir.

><c:forEach var="row" items="${databaseResult.rows}">

<c:url value="/addToBasketServlet">

<c:param name="productId" value="${row.dbProductId}

</c:url>

</c:forEach>

">

evnafetsa at 2007-7-13 18:06:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
You can use <c:param name="" value=""/> within <c:url> to pass parameters. If you don't want to use that, try with Javascript.
a_mathewa at 2007-7-13 18:06:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Thanks a lot. Sorry for the late reply, was offline for some days
piasonpa at 2007-7-13 18:06:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

Hie. Thanks for that reply but Ive just noticed that as much as I can attach parameters to certain variables, I still cant attach a parameter from a input text type of drop down menu.

What I mean is, the drop down menu general gets enclosed in a form but if Im to use the <c:url> tag for the other variables, that means there will be a conflict of the form action and the <c:url action>

piasonpa at 2007-7-13 18:06:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

drop down menu? where did theat come from?

You're not making much sense.

Basically you have to only pass the id of the line that you clicked on.

The easiest way to do that is with a link you click on.

If you can pass all the info you need in a URL with parameters, do that.

If you need to submit the entire form, then have a javascript onclick event that sets a hidden field for the value, and then submits the form.

evnafetsa at 2007-7-13 18:06:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

Sorry, its me who wasnt clear. I never double checked my question. Ive re-pasted the previous code below with some slight changes: If you look at the code, you will see that when someone clicks on add to basket, the <c:param> will carry the productID through the url: '/confect/confectioneryV2.jsp' invoked by the <c:url> tag.

Now, if I need to carry the typed in quantity e.g a user types in 5 for the quantity, how will I make that to be carried over to the same url above. In general I know you use a form but in this case, this will conflict with the <c:url> link for the add to basket. What I mean is, the <c:url> tag has the above url while a form might have a diffferent url enclosed in its action command.

(I WANT TO AVOID USING JAVASCRIPT AND STICK TO JSP AND HTML ONLY)

If I leave out the conflicting form, then the quantity will not be carried across to the same page where the productID within the <c:url> tag is being carried over to.

The same applies if I need to use a drop down menu instead of the text input.

PLEASE HELP

=====================================================

<table>

<tr>

<td>Product ID</td>

<td>Product Name</td>

<td>Price</td>

<td>Quantity</td>

<td>Add to Basket</td>

</tr>

<c:forEach var="row" items="${databaseResult.rows}">

<tr>

<td>${row.dbProductId}</td>

<td>${row.dbProductNm}</td>

<td>${row.dbPrice}</td>

<td><input type="text" name= "formQuantity" value= "0"/><td>

<td><a href= "<c:url value= '/confect/confectioneryV2.jsp'>

<c:param name='productId' value='${row.nameId}'/>

</c:url>"

> Add to Basket </a>>

</td>

</tr>

</c:forEach>

</table>

=====================================================

piasonpa at 2007-7-13 18:06:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...