Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6173183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:31:24+00:00 2026-05-23T23:31:24+00:00

I’ve taken over some old legacy JSP code and wanted to add some mail

  • 0

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:

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

etc

the code, sample taken off somewhere (not pretty…):

<%@ page import="java.util.*" %>
<%@ page import="javax.mail.*" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="javax.activation.*" %>

<%@ page session="true"%>
<html>
<head>
<title>JSP JavaMail Example </title>
</head>
<body>
<%
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);
%>
</body>
</html>

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.

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 yum just fine, but I think there is more to it then this at this point. Perhaps some Java config?

I just want to send a simple mail…

Any suggestions, much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:31:25+00:00Added an answer on May 23, 2026 at 11:31 pm

    The mail jars need to go in WEB-INF/lib, not in WEB-INF. You’ll need to restart the app or the entire tomcat server for it to take effect.

    From your description, I’m guessing you’re working with an exploded webapp directory found at $TOMCAT_HOME/webapps/. First thing to be aware of: if there’s a .war right next to the directory, then the war is the “source of truth”. A war is a Web ARchive. It’s basically a zip file containing an entire webapp directory, and Tomcat extracts that directory for performance purposes. What that means to you is that whatever you do to the directory, if that war file’s timestamp gets updated somehow, it will blow away all changes you’ve made to the directory and replace it with the contents of the war again.

    Now after that, all you should need in order to use the mail classes is a file structure like:

    $TOMCAT_HOME
        bin
        conf
        lib
        ...
        webapps
            <your app>
                test.jsp (Can be in any directory under <your app> except WEB-INF)
                WEB-INF
                    lib
                        mail.jar
                        activation.jar
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am writing an app with both english and french support. The app requests
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.