passing an int variable from one JSP to another
843836Jun 18 2004 — edited Oct 19 2004Dear Fellow Java Developers:
I have a straight forward question here. I have a jsp from which I am passing a parameter as follows:
<a href="productDescription.jsp?productID=1>name</a>
Now, inside productDescription.jsp, I have the following scriplet:
<% int itemID=request.getParameter(productID"); %">the problem is that request.getParameter() is returning a String and I need it to return an int, as productID is an int variable, and later on I use this int variable to perform a query in a mysql database where itemID is a primary key of type int in the table. I have tried casting as follows:
int itemID=(int)request.getParameter("productID");
int itemID=request.(int)getParameter("productID");
int itemID=request.getParamater(productID);
Integer itemID=(Integer)request.getParameter("productID");
but nothing seems to work. How should I cast the expression request.getParameter() so that it returns an int? Is there another method that I should be using instead?
Thanks in advance to all those that reply.
Sincerely;
Fayyaz
</a>