title: JSP: Session cannot be resolved to a type
body: <p>I've taken over some old legacy JSP code and wanted to add some mail support to it. Well, it didn't go so well, as I get errors, such as:</p>
  
  <pre class="lang-none prettyprint-override"><code>Session cannot be resolved to a type
  
  An error occurred at line: 39 in the jsp file: /xxxxx/test.jsp
  Message cannot be resolved to a type
  MimeMessage cannot be resolved to a type
  </code></pre>
  
  <p>etc</p>
  
  <p>the code, sample taken off somewhere (not pretty...):</p>
  
  <pre><code>&lt;%@ page import="java.util.*" %&gt;
  &lt;%@ page import="javax.mail.*" %&gt;
  &lt;%@ page import="javax.mail.internet.*" %&gt;
  &lt;%@ page import="javax.activation.*" %&gt;
  
  &lt;%@ page session="true"%&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;JSP JavaMail Example &lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;%
  String to = "sssssss@gmail.com";
  String from = "admin@yyyyyy.com";
  String subject = "subject";
  String messageText = "body";
  
  Properties props = System.getProperties();
  //props.put("mail.host", host);
  //props.put("mail.transport.protocol", "smtp");
  Session mailSession = Session.getDefaultInstance(props, null);
  
  Message msg = new MimeMessage(mailSession);
  msg.setFrom(new InternetAddress(from));
  InternetAddress[] address = {new InternetAddress(to)};
  msg.setRecipients(Message.RecipientType.TO, address);
  msg.setSubject(subject);
  msg.setSentDate(new Date());
  msg.setText(messageText);
  
  Transport.send(msg);
  %&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Googling indicated the actual mail jars may be missing, so I download javamail, extracted the jars and put them into the tomcat WEB-INF directory.  Without a change.</p>
  
  <p>This a rackhostcloud setup with CentOs (5.5?) on it.  This was configured by the old team (long gone).  Safe to say, I'm not going to be known as the best Linux admin around, but basic command line stuff is no problem.  I can run <code>yum</code> just fine, but I think there is more to it then this at this point.  Perhaps some Java config?</p>
  
  <p>I just want to send a simple mail...</p>
  
  <p>Any suggestions, much appreciated.</p>