getting price from 1 page to another page

ok i have a shopping cart jsp page which displays the price in the textbox.

<input type="text" name="textfield" size="10" disabled value=" <%=sum%>" />

i want this price to be displayed in another jsp page.

how do i do it?

[359 byte] By [anya_aaa] at [2007-11-27 3:56:37]
# 1

Do you mean on submitting the page?

In that case on the receiving JSP you'd write:

String receivedPrice = request.getParameter("textfield");

if ( receivedPrice == null || receivedPrice.length() == 0 )

throw new Exception ("Price value was not submitted");

But your code

<input type="text" name="textfield" size="10" disabled value=" <%=sum%>" />

will not work because as far as I know, disabled fields are not submitted with the form. You should make the field read-only to prevent the user from changing it but still be able to send the data on submit. I.e.

<input type="text" name="textfield" size="10" readonly="readonly" value=" <%=sum%>" />

nogoodatcodinga at 2007-7-12 9:00:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Or add a input type="hidden" field along a disabled field to pass it anyway.
BalusCa at 2007-7-12 9:00:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
i have the process like thisfrom my shopping cart page the user will go to form.jsp and then he will go to confirm.jspi want to display the total price from shoppingcart.jsp to confirm.jsp
anya_aaa at 2007-7-12 9:00:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Then on your form.jsp you should either receive the parameter into a readonly textfield, to display to the user, or as a hidden field to keep in the form but not display:

<input type="text" name="textfield" value="<%=request.getParameter("textfield")%>" readonly="readonly" />

OR

<input type="hidden" name="textfield" value="<%=request.getParameter("textfield")%>" readonly="readonly" />

Then, on your confirm.jsp, you'l again be able to receive the value with request.getParameter("textfield").

nogoodatcodinga at 2007-7-12 9:00:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...