You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Abhilash V. Sonwane" <ab...@elitecore.com> on 2000/08/21 08:46:51 UTC
Re : How to cast JSP request String to int?
this is basic java
use Integer.parseInt() method from the Integer class
----- Original Message -----
From: Thomas <li...@jps.net>
To: tomcat-user@jakarta.apache.org
Sent: Mon Aug 21 12:06:43 GMT+05:30 2000
Subject: How to cast JSP request String to int?
How do you use a number from a request parameter in an equation using JSP? In other words,
How do you set the value of an int variable to the value of a numeric String variable?
I tried to do:
int Repeat1__numRows = 10;
if(request.getParameter("num_results")!=null) {
Repeat1__numRows = (int)request.getParameter("num_results");
}
But the engine (tomcat 3.1 and jdk 1.3) says:
Invalid cast from java.lang.String to int
thanks for a tip,
Thomas
____________________________________________________________
eLitecore Technologies Pvt. Ltd.