• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic