jaya raman

Greenhorn
+ Follow
since Nov 08, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jaya raman

Hi Sagar,
Its quite simple....
First u set the path variable to the bin directory of jdk as well as bin directory of j2sdkee.
Second set the classpath variable to the jar files that r there in the j2sdkee and jdk.
once this is through u can go ahead compiling...
rgds,
jaya raman
23 years ago
Hi,
I just started learning EJB and I'm using J2sdkee 1.2.1 for my programs. I created a session Bean, which I had deployed successfully using the j2ee EJB server. After which when I tried running the client, I got the following error:
java.lang.ClassCastException at com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at MessageClient.main(MessageClient.java:20)
The client program code is:
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import ejb.ejbproj.message.Message;
import ejb.ejbproj.message.MessageHome;
public class MessageClient
{
public static void main(String[] args)
{
try
{
Context initial = new InitialContext();
Object objref = initial.lookup("MyMessage");
System.out.println(" initial lookup got....");

MessageHome home =(MessageHome) PortableRemoteObject.narrow(objref,
MessageHome.class);
System.out.println("got the reference....");
ejb.ejbproj.message.Message msg = home.create();
String s = msg.getMessage();
System.out.println("The message retrieved is.."+s);
s="Good afternoon...EJB's fine";
msg.setMessage(s);
System.out.println("The message retrieved is.."+s);
msg.remove();
}
catch (Exception ex)
{
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
}

Kindly help me out.
Thanks in advance.
regards,
jaya raman
Hi Sandeep,
I tried ur program to send emails using JavaMail but encountered the following exception:
javax.mail.MessagingException:could not connect to SMTP host :mail.yahoo.com, port:25,
java.net.NoRouteToHostException: Host Unreachable: no further information.
I used javawebserver2.0.
Could u pls. help me on this regard. Is anything wrong in the following piece of code(mail host):
prop.put("mail.smtp.host","mail.yahoo.com");
kindly suggest me.
rgds,
jayaraman

Originally posted by Sandeep Jain:
Hi ,
There are two ways through which you can send a mail ,
1) using the smtp Client
2) using javamail package.
If u wanna make use of java mail package, the code is as follows

import javax.mail.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.internet.*;
public class SendingMail2 extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)
{
try
{
res.setContentType("text/html");
String from = "uremailid eg sandeep_raparia@yahoo.com ";
String to = "recipents email id eg xyz@pqr.com";
String subject = "the subject u wanna send ";
String cc="cc addresses "
String bcc="Bcc address";
String text="the matter that u wanna send ";
java.util.Properties prop = System.getProperties();
prop.put("mail.smtp.host","mail.yahoo.com");
Session ses = Session.getInstance(prop,null);
MimeMessage message = new MimeMessage(ses);
try
{
Address fromAddress = new InternetAddress(from);
message.setFrom(fromAddress);
message.setSubject(subject);
Address[] toAddress = InternetAddress.parse(to);
Address[] cc_address=InternetAddress.parse(cc);
Address[] bcc_address=InternetAddress.parse(bcc);
message.setRecipients(Message.RecipientType.TO,toAddress);
message.setRecipients(Message.RecipientType.CC,cc_address);
message.setRecipients(Message.RecipientType.BCC,bcc_address);
message.setSentDate(new java.util.Date());
message.setText(text);
Transport.send(message);
}
catch(Exception e)
{
System.out.println("Problem " + e);
}
}
catch(Exception e)
{
}
}
};


23 years ago
Hi Sandeep,
I tried ur program to send emails using JavaMail but encountered the following exception:
javax.mail.MessagingException:could not connect to SMTP host :mail.yahoo.com, port:25,
java.net.NoRouteToHostException: Host Unreachable: no further information.
I used javawebserver2.0.
Could u pls. help me on this regard. Is anything wrong in the following piece of code(mail host):
prop.put("mail.smtp.host","mail.rediff.com");
kindly suggest me.
rgds,
jayaraman

Originally posted by Sandeep Jain:
Hi ,
There are two ways through which you can send a mail ,
1) using the smtp Client
2) using javamail package.
If u wanna make use of java mail package, the code is as follows

import javax.mail.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.internet.*;
public class SendingMail2 extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)
{
try
{
res.setContentType("text/html");
String from = "uremailid eg sandeep_raparia@yahoo.com ";
String to = "recipents email id eg xyz@pqr.com";
String subject = "the subject u wanna send ";
String cc="cc addresses "
String bcc="Bcc address";
String text="the matter that u wanna send ";
java.util.Properties prop = System.getProperties();
prop.put("mail.smtp.host","mail.yahoo.com");
Session ses = Session.getInstance(prop,null);
MimeMessage message = new MimeMessage(ses);
try
{
Address fromAddress = new InternetAddress(from);
message.setFrom(fromAddress);
message.setSubject(subject);
Address[] toAddress = InternetAddress.parse(to);
Address[] cc_address=InternetAddress.parse(cc);
Address[] bcc_address=InternetAddress.parse(bcc);
message.setRecipients(Message.RecipientType.TO,toAddress);
message.setRecipients(Message.RecipientType.CC,cc_address);
message.setRecipients(Message.RecipientType.BCC,bcc_address);
message.setSentDate(new java.util.Date());
message.setText(text);
Transport.send(message);
}
catch(Exception e)
{
System.out.println("Problem " + e);
}
}
catch(Exception e)
{
}
}
};


23 years ago
Hi Lokesh,
I tried ur program to send emails using JavaMail but encountered the following exception:
javax.mail.MessagingException:could not connect to SMTP host :mail.yahoo.com, port:25,
java.net.NoRouteToHostException: Host Unreachable: no further information.
I used javawebserver2.0.
Could u pls. help me on this regard. Is anything wrong in the following mail host:
private final String MAIL_HOST="mail.yahoo.com";
kindly suggest me.
regards,
jayaraman
mailid:jayaraman_g@usa.net

Originally posted by lokesh reddy:
Hi Nishant,
Here is the code u asked for
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;
import javax.activation.*;
public class MailSender extends HttpServlet
{
private final String MAIL_HOST="mail.sigmaonline.net";
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();

String from=req.getParameter("from");
String to=req.getParameter("to");
String subject=req.getParameter("subject");
String text=req.getParameter("text");
Properties prop=System.getProperties();
prop.put("mail.smtp.host",MAIL_HOST);
prop.put("mail.from",from);
Session session=Session.getDefaultInstance(prop,null);
try
{
Message message=new MimeMessage(session);
InternetAddress address[]={new InternetAddress(to)};
message.setRecipients(Message.RecipientType.TO,address);
message.setFrom(new InternetAddress(from));
message.setTo(to);
message.setSubject(subject);
message.setContent("text/plain",text);
Transport transport=session.getTransport(address[0]);
transport.addConnectionListener(new ConnectionHandler());
transport.addTransportListener(new TransportHandler());
transport.connect();
transport.sendMessage(message,address);
}
catch(Exception ex)
{
getServletContext().log(ex);
}
}
class ConnectionHandler extends ConnectionAdapter
{
public void opened(ConnectionEvent ce)
{
System.out.println("Connection Opened");
}
public void disconnected(ConnectionEvent ce)
{
System.out.println("Connection disconnected");
}
public void closed(ConnectionEvent ce)
{
System.out.println("Connection closed");
}
}
class TransportHandler extends TransportAdapter
{
public void messageTransferred(TransportEvent te)
{
System.out.println("Message Delivered");
}
public void messagePartiallyTransferred(TransportEvent te)
{
System.out.println("Message Partially Transferred");
}
public void messageNotTransferred(TransportEvent te)
{
System.out.println("Message Not Transferred");
}
}
}
Nishant, i dint tested this code, but i am sure that it works well, if there is any problem with this code please let me know it.
Loke.


23 years ago
Hi Haijun,
Well u have tutorials available under java.sun.com for jsp. U can find several tutorials on the web which can be found through any search engine.
Best of luck !!
rgds,
jaya raman
23 years ago
Can a find out whether the person who has logged in is a valid NT user and find the name of the user? If so how is it possible, could anyone let me know the code.
Thanx in advance,
rgds,
jaya
23 years ago