title: How to fix this exception? (getting exception while sending mail from jsp program to gmail account)
body: <p><strong>UPDATE:</strong> The Code working when I use it as java program. And When I run it as jsp it gives the following exception.
  <strong>java.security.AccessControlException: access denied (java.security.SecurityPermission insertProvider.SunJSSE)</strong></p>
  
  <p>I posted the code below. I got the following exception.How to resolve this? I already searched in google but did not find the solution :(
  **java.security.AccessControlException:</p>
  
  <pre><code>&lt;%@ page import="java.security.*" %&gt;
      &lt;%@ page import="javax.mail.internet.*" %&gt;
  &lt;%@ page import="javax.mail.*" %&gt;
  &lt;%@ page import="java.util.*" %&gt;
  &lt;%@ page import="java.io.*" %&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;%
  String name=request.getParameter("name");
  String from=request.getParameter("mail");
  String message1=request.getParameter("msg");
  try{   
  String toAddress="mymailid@gmail.com";
  String fromAddress=from;
  String fromName=name;
  String messageSubject="feedback"; 
  String messageBody1=message1;
  Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    Properties props=new Properties();  
    props.put("mail.smtp.host","smtp.gmail.com"); 
         props.put("mail.debug","true"); 
      props.put("mail.smtp.starttls.enable","true"); 
  Session session1 = Session.getDefaultInstance(props,new javax.mail.Authenticator() {
  
  protected PasswordAuthentication getPasswordAuthentication() {
  return new PasswordAuthentication("mailid@gmail.com", "Password");
  }
  });
    Message message=new MimeMessage(session1);
    message.setFrom(new InternetAddress( fromAddress, fromName));
    message.setRecipient(Message.RecipientType.TO,new InternetAddress( toAddress));
    message.setSubject( messageSubject);
    message.setText( messageBody1);
    message.setSentDate(new Date());
    Transport.send(message);
   }
  catch(Exception e)
  {out.println(e);
       }    
  %&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Help Me to fix this error</p>