• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

i am validating email on server side

 
Ranch Hand
Posts: 52
jQuery Netbeans IDE Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

https://coderanch.com/t/453931/Other-JSE-JEE-APIs/java/handle-wrong-mail-address-while
 
Ranch Hand
Posts: 56
Eclipse IDE Postgres Database Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
jQuery Netbeans IDE Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28296
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
jQuery Netbeans IDE Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
jQuery Netbeans IDE Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FWIW, the "real" regex for validating an email address is about a page long. It's actually somewhat entertaining.
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28296
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22803
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just use javax.mail.internet.InternetAddress to handle the validation for me.
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79707
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And anything with a regex that long is not a "beginning" topic.Moving thread.
 
Rob Spoor
Sheriff
Posts: 22803
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79707
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I take your point, Rob.
 
What are you doing in my house? Get 'em tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic