File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes i am validating email on server side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "i am validating email on server side" Watch "i am validating email on server side" New topic
Author

i am validating email on server side

Karamjeet singh
Ranch Hand

Joined: Feb 24, 2010
Posts: 52

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


Don't aim for success if you want it; just do what you love and believe in, and it will come naturally.
Vikas Nahar
Greenhorn

Joined: Mar 01, 2010
Posts: 4
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

Joined: Jul 05, 2009
Posts: 56

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

Joined: Feb 24, 2010
Posts: 52



i am putting this code outside processRequest method
if i put this inside it give me error
how can i do it
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

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

Joined: Feb 24, 2010
Posts: 52

i know that
but i want the value of that method to validate
how can i do it
Karamjeet singh
Ranch Hand

Joined: Feb 24, 2010
Posts: 52

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

Joined: Apr 01, 2009
Posts: 650
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

Joined: Sep 29, 2008
Posts: 12617

FWIW, the "real" regex for validating an email address is about a page long. It's actually somewhat entertaining.
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
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!


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

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

Joined: Oct 27, 2005
Posts: 19783
    
  20

I just use javax.mail.internet.InternetAddress to handle the validation for me.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1836
    
    7

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.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Oct 13, 2005
Posts: 40052
    
  28
And anything with a regex that long is not a "beginning" topic.Moving thread.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

Campbell Ritchie wrote:And anything with a regex that long is not a "beginning" topic.Moving thread.

Fixed
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
I take your point, Rob.
 
 
subject: i am validating email on server side