• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i am validating email on server side

 
Karamjeet singh
Ranch Hand
Posts: 52
Flex jQuery Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am validating email on server side
i have code of javascript whch validates
but i want pure java to validate
i ask from my faculty
she says you can do this by patterns
but i don't know where to start
 
Vikas Nahar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of validation are aiming at? Just the syntax validation?

Syntax validation can be done using parsers.
For a more detailed validation we are having a discussion on the following thread maybe it might help you.

http://www.coderanch.com/t/453931/Other-JSE-JEE-APIs/java/handle-wrong-mail-address-while
 
Charles 'King
Ranch Hand
Posts: 56
Eclipse IDE Postgres Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
karamjeet singh wrote:i am validating email on server side
i have code of javascript whch validates
but i want pure java to validate
i ask from my faculty
she says you can do this by patterns
but i don't know where to start



You're going to have to exert a little more effort if you want help. Post some code and ideas. Give us an idea of your skill level (Beginner, Intermediate, etc...). This isn't a code factory
 
Karamjeet singh
Ranch Hand
Posts: 52
Flex jQuery Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i am putting this code outside processRequest method
if i put this inside it give me error
how can i do it
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But that's just a basic question about Java programming, isn't it? You can't put a method inside another method regardless of whether it's validating an e-mail address or anything else.
 
Karamjeet singh
Ranch Hand
Posts: 52
Flex jQuery Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know that
but i want the value of that method to validate
how can i do it
 
Karamjeet singh
Ranch Hand
Posts: 52
Flex jQuery Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see i am receiving value from user
on the base of that value i am validating
from which method i can do this
any any hints
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
karamjeet singh wrote:see i am receiving value from user
on the base of that value i am validating
from which method i can do this
any any hints


Just call the validation method from within your processRequest method.

What's the problem? If you get an error, show the code that is causing the error and show us the error you're getting.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FWIW, the "real" regex for validating an email address is about a page long. It's actually somewhat entertaining.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FWIW, the "real" regex for validating an email address is about a page long. It's actually somewhat entertaining.


That made me curious so I found this: http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html ... gnarly!
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:FWIW, the "real" regex for validating an email address is about a page long. It's actually somewhat entertaining.

What is less entertaining is when somebody decides they have to validate e-mail addresses, so they implement a regex which determines your actual e-mail address is not valid.
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just use javax.mail.internet.InternetAddress to handle the validation for me.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:FWIW, the "real" regex for validating an email address is about a page long. It's actually somewhat entertaining.


I don't think it's even technically possible to write a regular expression that fully complies with the formal specification of a valid e-mail address. Syntax validation of an e-mail address doesn't really buy you a whole lot anyway. If you want to know that a user supplied e-mail address is valid and in use, just send a verification e-mail to the address containg a deeplink with an activation UID. It's a little more hassle for the user, but a far more useful means of validation.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although this regex assumes comments have been stripped.

http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html

This has been on the internet for a long time, and is reasonably complete.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50189
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And anything with a regex that long is not a "beginning" topic.Moving thread.
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:And anything with a regex that long is not a "beginning" topic.Moving thread.

Fixed
 
Campbell Ritchie
Sheriff
Pie
Posts: 50189
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I take your point, Rob.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic