aspose file tools*
The moose likes Java in General and the fly likes How to Validate the Integers doesnot allow the string values using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to Validate the Integers doesnot allow the string values using java" Watch "How to Validate the Integers doesnot allow the string values using java" New topic
Author

How to Validate the Integers doesnot allow the string values using java

Kumar Naidu
Greenhorn

Joined: Jul 27, 2006
Posts: 11
Hi all

i have one bean that bean contains string and integer values setter and getter method i am writen the validations integer variables and string variables sucessfully. but i am entered the values in jsp form integer place string values entered that time 500 error is retrived. how to write the Integer text boxes allow the strings the time does not fire the 500 error. only Retrive the Error messageas. i am using Pattern and matcher classes.

Regards
Vinay
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
...but i am entered the values in jsp form integer place string values entered that time 500 error is retrived.


It looks from your post that textfield require integer and if user enters String, 500 internal server errors at the server side.

From the textfield, the retrieved value will always be a string. You can use valueOf(String) method for validation. It returns you an Integer object. If it fails, you will get a NumberFormatException.


By parsing, you can filter illegal entered values.

Is this you are looking for?


- Naseem


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Validate the Integers doesnot allow the string values using java
 
Similar Threads
bean:write and integer properties
DynaValidtorform
Padding for Numeric values
Compile error
Icefaces & Ejb3