hi,
i want to send e-mail using jsp. when i run my code no error is shown but the message is not
sent to email address.
here is the code

<html>

<body>

<form  method=post   action="aa.jsp"           >

sender<input type=text name=text1><br>
Reciever<input type=text name=text2><br>
Subject<input type=text name=text3><br>
Message<textarea name='area1' rows=5 cols=30>                  
</textarea>
<input     type=submit>

</form>

</body>

</html>
<%@page language="java" import="java.io.*,javax.activation.*,javax.servlet.*,javax.servlet.http.*, javax.mail.*,javax.mail.internet.*,javax.mail.event.*, java.net.*,java.util.*,com.mysql.jdbc.Driver" session="true" %>
<%
	
        response.setContentType("text/html");

        try

        {
	  out.println("acb");
	 Properties props=new Properties();
       
        props.put("mail.smtp.host", "smtp.jcom.net");
     
          

       

   Session   session1  =  Session.getDefaultInstance(props,null);

           String s1 = request.getParameter("text1"); 

           String s2 = request.getParameter("text2");
  out.println("acb");
           String s3 = request.getParameter("text3");

           String s4 = request.getParameter("area1");

     Message message =new MimeMessage(session1);

      message.setFrom(new InternetAddress(s1));

      message.setRecipients

              (Message.RecipientType.TO,InternetAddress.parse(s2,false));

           message.setSubject(s3);

           message.setText(s4);        
  out.println("acb");
           Transport.send(message);

  out.println("acb");
           out.println("mail has been sent");

        }

        catch(Exception ex)

        {

           System.out.println("ERROR....."+ex);

        }

 %>

Not only are you abusing JSP for something it's not meant to be used for, but you're also eating exceptions (catching them without doing anything with them).

No wonder you don't get to see errors if you don't log them.

1) always log or otherwise handle any exception you catch
2) never use Java code in JSP
3) never use JSP for anything except displaying results to the client, use servlets instead.

i am new to jsp so can i get the coding for sending e-mail in jsp and the steps i will have to follow..

This article has been dead for over six months. Start a new discussion instead.