Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

passing an int variable from one JSP to another

843836Jun 18 2004 — edited Oct 19 2004
Dear 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>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2004
Added on Jun 18 2004
5 comments
334 views