Meaningless Drivel is fun!
The moose likes Other JSE/JEE APIs and the fly likes java mail through jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "java mail through jsp" Watch "java mail through jsp" New topic

java mail through jsp

susham kumar

Joined: Jul 20, 2011
Posts: 2

hi, i have used java mail for sending mail by making gmail as smtp server... its getting executed as and desktop application but when it comes to web application i couldn't execute it. problem is with the authentication class which is included in my application
class PasswordAuthenticator extends

javax.mail.Authenticator {
public PasswordAuthentication

getPasswordAuthentication() {
String user = "****************";
String pwd = "********";
return new PasswordAuthentication(user, pwd);

this class is called in the main program, of my mail application.. how to include both the classes in web.xml file when i use servlets and how to include both main class and the above class in JSP.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

You don't need to declare your authenticator class in web.xml. Neither do you need to import it in your JSP, if you are still writing antiquated JSP code which has embedded Java. All you need to do is make sure it gets deployed with your web application along with your other classes. It should go either in WEB-INF/classes or else in a jar in WEB-INF/lib.
I agree. Here's the link:
subject: java mail through jsp
It's not a secret anymore!