• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 27214
87
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: 27214
87
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: 22650
126
Eclipse IDE Spring VI Editor 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: 75716
354
  • 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: 22650
126
Eclipse IDE Spring VI Editor 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: 75716
354
  • 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.
 
Paper beats rock. Scissors beats tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic