I'm using a socket server that is based off of java and it allows java extensions to be implemented that allow server side login to be performed. I want to create a signup/login system but I'm struggling with finding a way to validate/filter user input before manipulating with the database.

1. I want to check for the type (string or integer)
2. I want to check for the length of strings to ensure they are within a given range
3. I want to be able to determine if a field contains a valid email address
4. I want to be able to remove invalid characters easily from any string
5. I want to sanitize before using with database.

Does Java have an easy way for me to do all of these things?
If anyone knows of a free class, framework, library that handles all of these tasks, please let me know about it.

Ricky

Recommended Answers

All 2 Replies

1. I want to check for the type (string or integer)
http://www.daniweb.com/forums/announcement9-2.html

2. I want to check for the length of strings to ensure they are within a given range
http://www.daniweb.com/forums/announcement9-2.html

3. I want to be able to determine if a field contains a valid email address
http://www.daniweb.com/forums/announcement9-2.html

4. I want to be able to remove invalid characters easily from any string
http://www.daniweb.com/forums/announcement9-2.html

5. I want to sanitize before using with database.
http://www.daniweb.com/forums/announcement9-2.html

commented: Helpful! +6

I'm using a socket server that is based off of java and it allows java extensions to be implemented that allow server side login to be performed. I want to create a signup/login system but I'm struggling with finding a way to validate/filter user input before manipulating with the database.

1. I want to check for the type (string or integer)
2. I want to check for the length of strings to ensure they are within a given range
3. I want to be able to determine if a field contains a valid email address
4. I want to be able to remove invalid characters easily from any string
5. I want to sanitize before using with database.

Does Java have an easy way for me to do all of these things?
If anyone knows of a free class, framework, library that handles all of these tasks, please let me know about it.

Ricky

Some of these things might be desirable, but surely it would be a waste of time to actually search for code out there that would verify the length of the String for you? You *should* be able to write that piece of code in under 10 seconds. And PS, the only way to determine if an email address is valid is to email that address and require some type of a response from the account holder. On sites like daniweb this is done through some type of auto generated link that is sent to the email provided. Obviously you could also have some BS addresses that don't fit the right format (something@something.com/edu/whatever) but it is really a waste of time to check for that. I would look into what I said about the link generation if you're serious about this project.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.