| Author |
Why jsp can't send javamail?
|
lyo Yashnoo
Ranch Hand
Joined: Sep 15, 2003
Posts: 50
|
|
Hi everyone: I am writing javamail in jsp using Tomcat.I set the Session in Tomcat console.It is "mail/session". In jsp my code is: //////////////////////////////////////////////////////////////////////// Context ctx=new InitialContext(); Session session=(Session)ctx.lookup("mail/session"); Message message=new MimeMessage(session); message.setFrom(new InternetAddress(mailfrom)); But when I click the send mail button,Tomcat report error: ////////////////////////////////////////////////////////////////////// javax.naming.NameNotFoundException: Name mail is not bound in this Context But I have set the "session" value in console indeed. Even I change the code to "Session session=(Session)ctx.lookup("java:comp/env/mail/session");" It also can't work.Tomcat says:"javax.naming.NameNotFoundException: Name java:comp is not bound in this Context" Why this happen?I found that the situaction happen usually when I use like datasource,Mail.Tomcat isn't steady?
|
 |
lyo Yashnoo
Ranch Hand
Joined: Sep 15, 2003
Posts: 50
|
|
I send the mail in servlet.But it alway says :"ENCOUNTERED EXCEPTION: javax.naming.NameNotFoundException: Name java:comp is not bound in this Context ". But I had set the value in Tomcat console.The Tomcat's example:javamail can run property.Have someone come across this problem? :roll:
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
Perhaps someone in the Tomcat forum would be more familiar with this. bear
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Mike Curwen
Ranch Hand
Joined: Feb 20, 2001
Posts: 3695
|
|
what console would that be? What does your server.xml file look like? As an aside, if you're doing this in a JSP, you might want to choose a different variable name than 'session'.
|
 |
 |
|
|
subject: Why jsp can't send javamail?
|
|
|