Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Client Scripting
Expertise: Beginner
Apr 8, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Logging users' e-mail addresses

Is there a way to log my users' e-mail addresses using Java?

I thought of using a mailto form but the user would have to press a button, making this inconvenient and messy for me to access!

I am getting about four hits a day on a site that is not advertised and is really meant as a way for me to access my backed-up reports from school! I would like to see who is on my site and e-mail them to find out how they found it.

I also want to implement a warning informing users that their e-mail addresses are being logged. I know it can be done because I have been getting e-mail from sites that I have visited and I never sent them mail or clicked any buttons other than links. If you can assure me this is possible, and maybe send me the code, I would greatly appreciate it!

You cannot obtain a user's e-mail address using Java applets, and that's a good thing. Java's security manager prevents applets from querying system resources such as the user's name or home directory. This is to prevent malicious applets from collecting this data and abusing it for aan evil purpose like spoofing e-mail messages from the unsuspecting user's computer system and so forth. Java is not the right answer here.

Your Web server, on the other hand, has complete knowledge of who's connecting to the Web site to retrieve HTML files. So you could, for example, embed a CGI script reference in your HTML pages that collected that information and saved it in a file on your server system somewhere.

This is how several web page "hit" counters work. It will tell you at least which systems are connecting to your Web site -- but it won't let you know the user's e-mail address.

What you've seen on Web pages is probably done using some incarnation of CGI script backends, or they've used JavaScript. Unlike Java, JavaScript is not very strict about security (in fact it has some very serious security flaws) and does allow the Web page to find out things like the user's e-mail address and then pass that information to the Web server, where it can be saved for later use.

If you really want to try that (some would argue this is a highly unethical thing to do) I suggest you look at JavaScript.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date