This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I don't why it is happening. When I am trying to call the MailSend class from a JSP page it is showing exception. But , if call the same MailSend class from a Java program , it is not showing any exception.
Why is it happening ?
I am giving you both the JSP page and the Plain Java class.
Here is the content of testmail.jsp :
And the stacktrace while running testMail.jsp
And here is the MailTest2.java , which works perfectly fine:
I am puzzled , can you tell me why this is happening . They are calling the same instance , while one is working fine , another one is generating exception.
It's a Security exception - that means the servlet container is running with a security manager enabled that forbids something you're trying to do. Try running the servlet container with a less restrictive security manager (or no security manager at all).
Desktop apps are typically run without a security manager, which is why you don't get the exception there.