title: How to send email with servlet?
body: <p>I am making a email submit form in html and the email is sent with Microsoft Outlook when user hit "submit". Here is my code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;script type="text/javascript"&gt;
      function sendMail() {
          var link = "mailto:jshao745@gmail.com"
                          + "&amp;subject=" + encodeURIComponent (document.getElementById('subject').value)
                          + "&amp;body=" + encodeURIComponent (document.getElementById('body').value)
                  ;
  
          window.location.href = link;
      }
  &lt;/script&gt;
  &lt;style&gt;
      textarea
      {
          resize: none;
      }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  subject:&lt;br&gt;
  &lt;input type="text" name="subject" id="subject"&gt;&lt;br&gt;
  Type your message here:&lt;br&gt;
  &lt;textarea rows="4" cols="50" id="body"&gt;
      This is a email testing.
  &lt;/textarea&gt;
  &lt;button onclick="sendMail(); return false"&gt;Send&lt;/button&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How do I make change so that the email is directory sent from webpage (or JSP to be exact) to my gmail without going through Outlook? I also try to add input field for sender's email address and name in the above form. I know I need to have a servlet for this to work. </p>
  
  <p>I use java 7 and tomcat 7.0.</p>
  
  <p>I appreciate if someone could help me.</p>