The Artima Developer Community
Sponsored Link

Java Answers Forum
Choosing between session.getDefaultInstance,session.getInstance in javamail

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Sivaramkrishnan Subramanian

Posts: 1
Nickname: sivaram101
Registered: Dec, 2002

Choosing between session.getDefaultInstance,session.getInstance in javamail Posted: Dec 30, 2002 3:42 PM
Reply to this message Reply
Advertisement
Hi ,
I am using the javamail api in a webapplication we are developing.
In order to pass a session object to the constructor of a MIMEMessage object I was using the syntax
Session session = Session.getDefaultInstance(props, null);
where props was the property object that contained information like SMTPHost etc.
It works fine for all scenarios except where I need to update the property of the session for e.g if I had given a wrong SMTP host name and I now want to change it, the change is not reflected till I restart the web server.
The definition of the getDefaultInstance method syas that is is expected behviour since in case of getDefaultInstance the properties are read by the session object the very first time it is created .After that it is ignored.
The other alternative would be to use the session.getInstance() method which creates a new session object on every call.
I just wanted to know whether there is any major downside
in using the getInstance method instead of thegetDefaultInstance method since there will a lot of emails sent in our application due to a comprehensive notifiaction mechanism.
Thanks in advance.
Regards,
Siva S

Topic: print Previous Topic   Next Topic Topic: net connection problems in java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use