• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to pass2 parameters from jsp to servelt

 
Ranga Reddy shreya
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,
Ihave to send 2 parameters to my servlet from jsp with this code one will come from java database, other will come from webpage like entering the quantity.
But my problem is my code is abel to get sku but not quantity. This is my jsp look like. Give me an idea if there is an alternative


<BR>ENTERQUANTITY<INPUTtype="text" name="Quantity1" size="12">
<td CLASS="TDBasicLeft"><aHREF="/cyberstore/html/ShoppingCartServlet?psku=<%=output.getSku()%>" CLASS="LinkBold"> AddToCart
Thanks
Ranga
 
rahul V kumar
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are sending only sku to servlet. IF you wish to send qty then add that to the url

<a href="my_servlet?sku=sku_num&qty=qty_num">Add to cart </a>
 
Ranga Reddy shreya
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks for u r reply..
But tried that too
In that case url is like this.. it's not taking quantity from that test box..
what to do
localhost:9080/cyberstore/html/ShoppingCartServlet?psku=7777&quantity=quan
Thanks
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to add some javaScript to implement this.

<a href=............ is already written to your genrated HTML code.

it will not pick the value of text box itself .

either submit your page or use javaScript as per your requiremnt.
 
Giuoco Krag
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you have to choose either GET "or" POST as your method for submitting a form. Not both? Maybe you can use a Hidden form variable instead of a query string. This will make all variables use the same method.

I think this will make it so you are only using a GET.

(Please correct if I got that backwards).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!