> -----Original Message-----
> From: A mailing list about Java Server Pages specification
> and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Reeta Mittal
>
> I am having a text box in my jsp page which will always have Integer
> values. Now by default all values from a text box are of type
> strings. Now
> how can I convert this to int type. I am using following line
> but it is
> giving error because we can not cast from primitive type to
> reference type.
>
> Position=(int) request.getParameterValues("Position") + 1;
>
> Can anybody tell me the way of doing this ?
I use constructs like this:
int position;
try {
position = new
Integer( request.getParameterValues("Position") ).intValue();
} catch( MalformedNumberException mne ) {
// Set value required if non-numeric value was entered
position = -1;
}
Note the Java convention of lowercase for first letter of variable/object
names and upper case first letter for classes.
> I am facing a very basic problem.
For future reference, I suggest you take a look at one of the general Java
programming FAQs:
eg
http://www.afu.com/javafaq.html
Steve S
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html