Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!

Alex Marks

Ranch Hand
+ Follow
since Sep 12, 2005
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 Alex Marks

I am writting a simple program to send the email. But i face to an problem/exception as below:
java.lang.NoClassDefFoundError: com/sun/activation/registries/LodSupport.
What do i need to do to solve such exception ?
Thank you very much for your help and have a good day !
12 years ago
Good Day to everyone,
I have developed a Chat Program in Java as my assignment, so far it works fine but my lecturer as me to improve it to overcome the potential problems. I really really dont know what the potential problems are. Would you please help me by identifying the potential problems for that problems ?
Thank you very much for any suggestions ! Thank you !
12 years ago
Thank you very much Frank Carver for your suggestion, i will try! Hava a nice day !
12 years ago
Hi everyone.
I have a strange problem with sending email via a servlet. The code was fine and i am able to send the email. But after sending about 3 times with a account (yahoo or gmail), i encounter an exception: javax.mail.AuthenticationFailedException. Then I change to another account. It works fine. After 3 times, the exception occurs again.
Please help me with this problem.
12 years ago
Thank you very much for your suggestion, i have found the solution.
12 years ago
JSP
Hi Everyone,
I have the problem with refresh page. I have 2 JSP pages, a.jsp and b.jsp. In a.jsp, I display the information which is stored in the session. In b.jsp, I make some modifications to such information. When i come back a.jsp, the page still display the old information, but after press F5 or refresh button of the web's browser, it displays new information. I would like to ask if there is any way to over-come this problem.
Thank you for your help so much and have a nice day.
12 years ago
JSP
I am dealing with the Callable Statement. Here is the code:

...
int id = 0;
String cal = "{ ? call returnlastrow }";
CallableStatement statement = null;
connection.prepareCall(cal);
statement.registerOutParameter(1,Types.INTEGER);
statement.execute();
id = statement.getInt(1);
statement.close();
...

I encounter an exception as : java.sql.SQLException: Malformed SQL92 string at position: 5. Expecting "=" got "c" 0

Please help me solve this problem. Thank you for your help.
I am using the TOMCAT as the web server for application development. Is there any way to make my pc as the Web Server, that outside users can access like the real host. I heard that it can be done be using LINKSYS router ?
if posible, please help me. Thank you very much !
12 years ago
Makarand Parab, Thank you very much, finally it works. Thank you again and again Cheers.
12 years ago
Makarand Parab, would you please more specific about your code? i think i could not get you ! thank you for you help !
12 years ago
Annie Smith, actually the code above I copy from the Internet and modify, but someone can use it,someone cannot use it,i am the one cannot use ! really dont understand why it cause error !
Hope to get helps from others ! thank you very much !
12 years ago
Thank you very much for your advices.
I have tried to search throught Internet, I manage to find the code to send Email with SSL. However I encounter problem. Here is the code.
public class SendingEmail {
private static final String SMTP_HOST_NAME = "smtp.gmail.com";
private static final String SMTP_PORT = "465";
private static final String emailMsgTxt = "Test Message Contents";
private static final String emailSubjectTxt = "A test from gmail";
private static final String emailFromAddress = "from@gmail.com";
private static final String SSL_FACTORY "javax.net.ssl.SSLSocketFactory";
private static final String[] sendTo = { "to@gmail.com"};

public static void main(String args[]) throws Exception {

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

new SendingEmail().sendSSLMessage(sendTo, emailSubjectTxt,
emailMsgTxt, emailFromAddress);
System.out.println("Sucessfully Sent mail to All Users");
}

public void sendSSLMessage(String recipients[], String subject,
String message, String from) throws MessagingException {
boolean debug = true;

Properties props = new Properties();
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
props.put("mail.smtp.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
props.put("mail.smtp.socketFactory.fallback", "false");

Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {

protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("from@gmail.com", "123456");
}
});

session.setDebug(debug);

Message msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);

InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);

// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
--------------------------------------------------------------------
The error is : Credentials Rejected.
Please help me to solve this problem ! thank you ! forgive me if this thread is not related to Servlets.
12 years ago
Annie Smith, I have tried your solution and I have the same error. Any ideas from you ? Thank you in advanced.
12 years ago
thank you very much Annie Smith, let me try your solution and let you know the result later ! thank you again ! cheers !
12 years ago
I am using a Servlet with to send a email. But i faced a error while sending email. Here is the code:
...
Properties props = new Properties();
props.setProperty("mail.transport.protocol","smtp");
props.setProperty("mail.host","smtp.gmail.com");
props.setProperty("mail.user","abc");
props.setProperty("mail.password","abc");
Session mailSession = Session.getDefaultInstance(props,null);
Transport transport = mailSession.getTransport();

MimeMessage message = new MimeMessage(mailSession);
message.setContent("This is a test","text/plain");
message.addRecipient(Message.RecipientType.TO,new InternetAddress("abc@yahoo.com"));
transport.connect();
transport.sendMessage(message,message.getRecipients(Message.RecipientType.TO));
transport.close();
...

The error i get is : javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first 38sm1046192nzk

Thank you for your help and looking for your replies.
12 years ago