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

  • SEARCH
  • Home
  • 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 8398017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:55:45+00:00 2026-06-09T20:55:45+00:00

I am trying to design a jsp page where I can send an e-mail

  • 0

I am trying to design a jsp page where I can send an e-mail but the code which is properly running in core java is giving me exception when used in jsp code. I believe I have properly placed my mail.jar in lib.

The current jsp code is:

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>

                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

                <html>
                <body>

                <%@ page import="java.util.Properties" %>               
                <%@ page import="javax.mail.Message" %>
                <%@ page import="javax.mail.MessagingException" %>
                <%@ page import="javax.mail.PasswordAuthentication" %>
                <%@ page import="javax.mail.Session" %>
                <%@ page import="javax.mail.Transport" %>
                <%@ page import="javax.mail.internet.InternetAddress" %>
                <%@ page import="javax.mail.internet.MimeMessage" %>


                <%
                Properties props = new Properties();
                        props.put("mail.smtp.host", "smtp.gmail.com");
                        props.put("mail.smtp.socketFactory.port", "465");
                        props.put("mail.smtp.socketFactory.class",
                                "javax.net.ssl.SSLSocketFactory");
                        props.put("mail.smtp.auth", "true");
                        props.put("mail.smtp.port", "465");

                 Session.getDefaultInstance(props,
                            new javax.mail.Authenticator() {
                                protected PasswordAuthentication getPasswordAuthentication() {
                                    return new PasswordAuthentication("prakash.d2222","**************");
                                }
                            });

                        try {

                            Message message = new MimeMessage(session);
                            message.setFrom(new InternetAddress("from@no-spam.com"));
                            message.setRecipients(Message.RecipientType.TO,
                                    InternetAddress.parse("prakash_d22@rediffmail.com"));
                            message.setSubject("hi");
                            message.setText("12345" +
                                    "\n\n No spam to my email, please!");

                            Transport.send(message);

                            System.out.println("Done");

                        } catch (MessagingException e) {
                            throw new RuntimeException(e);
                        }
                %>
                </body>
                </html>

and the error that I’m seeing is:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 37 in the jsp file: /pizza/page/ssl.jsp
The constructor MimeMessage(HttpSession) is undefined
  • 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-06-09T20:55:47+00:00Added an answer on June 9, 2026 at 8:55 pm
    Message message = new MimeMessage(session ); // error
    

    In JSP page session is a implicit object which is actually javax.servlet.http.HttpSession.

    I think you are confused with HttpSession and mail javax.mail.Session.Session. Change you
    code like –
    …

     Session mailSession = Session.getDefaultInstance(props,
                                    new javax.mail.Authenticator() {
                                        protected PasswordAuthentication 
                                              getPasswordAuthentication() {
                                            return new PasswordAuthentication
                                              ("prakash.d2222","**************");
                                        }
                                    });
    

    …

    Message message = new MimeMessage(mailSession );
    

    …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to design a page layout with two floated divs which I want
I'm trying to design a tree class in C++, but I'm running into some
I am trying to design a location lookup in which the user can specify
I'm trying to design a theme on WordPress (version 3.3.2) but I am having
I am trying to design my Class Diagram. But I get stuck on this
I am trying to design a layout so that I can change the views
I'm trying to design a font selection tool where a user can select one
i am trying to design a page by CSS , the problem is when
I'm trying to design a button with orange background and rounded borders but the
My team is trying to design a mail client for lotus notes on iPad.

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.