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.