Reputation: 1378
I'm currently developing an JavaEE application and I have to implement a feature, were users can define their own SMTP servers as a sender for notification mails. I already have an application which does the same task but in a standard JavaSE application. I did some research and found out, that the application server we are using (Glassfish 3.X) has a configuration menu in the admin panel for mail servers. So my question is: What is the difference between sending an mail from a JavaEE and a normal JavaSE application and if my working sources from the JavaSE application should also work in my enterprise app?
Best regards
Upvotes: 1
Views: 517
Reputation: 32953
Consider the definition of javamail sessions in the appserver as a convenience, a feature that helps standardize the configuration of application instances by pulling the configuration of services out of the application, and into the application server.
However, nothing will stop you from using a manually and dynamically defined javamail session in the appserver.
So, where in your SE program you'd configure a mail session, ending in
// typically a set of
properties.put("mail.smtp.port", "25");
// that are used to configure the Session
Session session = Session.getDefaultInstance(properties);
you'll typically find
@Resource(lookup = "sessionAsDefinedInGF")
private Session session;
in an EE application. From that point on both programs can be identical, in the latter the entire intialization and management of the session object will be performed by the appserver.
But as stated above, although the latter is a whole lot more convenient in most situations because the configuration is outside of the application, nothing will hold you back if you do the former, ie the SE style manual configuration of a Session.
Upvotes: 2