Welcome, Guest. Please login or register.
Did you miss your activation email?
Pages: [1]   Go Down
  Print  
Author Topic: Access to default session deniedAccess to default session denied  (Read 923 times)
0 Members and 1 Guest are viewing this topic.
jazz2k8
Yo Maaan Cheer Up...
Member
*

Reputation: 0
Offline Offline
Posts: 82
Referrals: 0

WWW Awards
« on: March 09, 2009, 08:48:52 AM »

Code
GeSHi (geshi):
  1.  
  2. <%@ page import="javax.mail.PasswordAuthentication,java.uti l.Date,java.util.Properties,javax.activation.DataH andler,javax.activation.FileDataSource,javax.mail. Message,javax.mail.MessagingException,javax.mail.M ultipart,javax.mail.Session,javax.mail.Transport,j avax.mail.internet.InternetAddress,javax.mail.inte rnet.MimeBodyPart,javax.mail.internet.MimeMessage, javax.mail.internet.MimeMultipart" %>
  3.  
  4.  
  5.  
  6. <%
  7. String from = "abcd@gmail.com";
  8. String to[] = {"abcd@gmail.com"};
  9. String subject = "Password Recovery";
  10. String bodyText = "The information contained in this electronic message and any attachments to this message are intended for exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at xyz@mycony.com immediately and destroy all copies of this message and any attachments. The views expressed in this E-mail message / Attachments, are those of the individual sender.";
  11.  
  12.  
  13. Properties props = new Properties();
  14. props.put("mail.smtp.host", "smtp.gmail.com");
  15. props.put("mail.smtp.auth", "true");
  16. props.put("mail.debug", "true");
  17. props.put("mail.smtp.port", "465");
  18. props.put("mail.smtp.socketFactory.port", "465");
  19. props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
  20. props.put("mail.smtp.socketFactory.fallback", "false");
  21.  
  22. Session s = Session.getDefaultInstance(props,new javax.mail.Authenticator() {
  23. protected PasswordAuthentication getPasswordAuthentication() {
  24. return new PasswordAuthentication("abcd@gmail.com", "pwd1234");
  25. }
  26. });
  27.  
  28.  
  29. try {
  30. MimeMessage message = new MimeMessage(s);
  31. message.setFrom(new InternetAddress(from));
  32. for(int i=0;i<to.length;i++){
  33. message.setRecipient(Message.RecipientType.TO, new InternetAddress(to[i]));
  34. message.setSubject(subject);
  35. message.setSentDate(new Date());
  36.  
  37. //
  38. // Set the email message text.
  39. //
  40. MimeBodyPart messagePart = new MimeBodyPart();
  41. messagePart.setText(bodyText);
  42.  
  43. //
  44. // Set the email attachment file
  45. //
  46. /*MimeBodyPart attachmentPart = new MimeBodyPart();
  47. FileDataSource fileDataSource = new FileDataSource(filename) {
  48. @Override
  49. public String getContentType() {
  50. return "application/octet-stream";
  51. }
  52. };
  53. attachmentPart.setDataHandler(new DataHandler(fileDataSource));
  54. attachmentPart.setFileName(filename);*/
  55.  
  56. Multipart multipart = new MimeMultipart();
  57. multipart.addBodyPart(messagePart);
  58. // multipart.addBodyPart(attachmentPart);
  59.  
  60. message.setContent(multipart);
  61.  
  62. Transport.send(message);
  63. }
  64. } catch (MessagingException e) {
  65. e.printStackTrace();
  66. }
  67.  
  68. %>
Created by GeSHI 1.0.7.20

When i run this code first time it works perfect and 2nd time it gives error:
Access to default session denied

Thanks and Regards,
Logged

visit my blog: www.yoteam.co.cc
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2593
Referrals: 13

WWW Awards
« Reply #1 on: March 09, 2009, 01:42:43 PM »

check if the current session is locked or removed.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
jazz2k8
Yo Maaan Cheer Up...
Member
*

Reputation: 0
Offline Offline
Posts: 82
Referrals: 0

WWW Awards
« Reply #2 on: March 10, 2009, 01:21:26 AM »

Issue Resolved
Code
GeSHi (geshi):
  1.  
  2. Session s = Session.getInstance(props,new javax.mail.Authenticator() {
  3.  
Created by GeSHI 1.0.7.20


thanks for ur time n support

« Last Edit: March 10, 2009, 08:21:06 AM by jazz2k8 » Logged

visit my blog: www.yoteam.co.cc
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2593
Referrals: 13

WWW Awards
« Reply #3 on: March 10, 2009, 09:06:02 AM »

Issue Resolved
Code
GeSHi (geshi):
  1.  
  2. Session s = Session.getInstance(props,new javax.mail.Authenticator() {
  3.  
Created by GeSHI 1.0.7.20


thanks for ur time n support



Glad u fixed it.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here