Results 1 to 3 of 3
- 03-01-2009, 11:49 AM #1
Servlet Error -illegal start of expression
hello Everybody,
I have written code to send mail to someone's mailbox
when I am compiling the code it is displaying 2 errors
here is my code :
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.net.*;
public class Mails extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
{
printwriter out=response.getwriter();
response.setcontenttype("text/html");
{
String d_email = "immigration@gmail.com";
String d_password = "mitsproject";
String d_host = "smtp.gmail.com";
String d_port = "465";
String[] m_to={"raghu9198@gmail.com"};
String m_subject = "Testing";
String m_text = "Hey, this is the testing email using smtp.gmail.com.";
public synchronized static boolean sendMail(String userName,String passWord,String host,String port,String starttls,String auth,boolean debug,String socketFactoryClass,String fallback,String[] to,String[] cc,String[] bcc,String subject,String text)
{
Properties props = new Properties();
props.put("mail.smtp.user", userName);
props.put("mail.smtp.host", host);
if(!"".equals(port))
{
props.put("mail.smtp.port", port);
}
if(!"".equals(starttls))
{
props.put("mail.smtp.starttls.enable",starttls);
props.put("mail.smtp.auth", auth);
}
if(debug)
{
props.put("mail.smtp.debug", "true");
}
else
{
props.put("mail.smtp.debug", "false");
}
if(!"".equals(port))
{
props.put("mail.smtp.socketFactory.port", port);
}
if(!"".equals(socketFactoryClass))
{
props.put("mail.smtp.socketFactory.class",socketFa ctoryClass);
}
if(!"".equals(fallback))
{
props.put("mail.smtp.socketFactory.fallback", fallback);
}
try
{
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
MimeMessage msg = new MimeMessage(session);
msg.setText(text);
msg.setSubject(subject);
msg.setFrom(new InternetAddress("immigrationportal@gmail.com"));
for(int i=0;i<to.length;i++)
{
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to[i]));
}
for(int i=0;i<cc.length;i++)
{
msg.addRecipient(Message.RecipientType.CC, new InternetAddress(cc[i]));
}
for(int i=0;i<bcc.length;i++)
{
msg.addRecipient(Message.RecipientType.BCC, new InternetAddress(bcc[i]));
}
msg.saveChanges();
Transport transport = session.getTransport("smtp");
transport.connect(host, userName, passWord);
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
return true;
}
catch (Exception mex)
{
mex.printStackTrace();
return false;
}
}
}
}
}
And My errors are :
---------- compile ----------
Mails.java:42: illegal start of expression
public synchronized static boolean sendMail(String userName,String passWord,String host,String port,String starttls,String auth,boolean debug,String socketFactoryClass,String fallback,String[] to,String[] cc,String[] bcc,String subject,String text)
^
Mails.java:117: ';' expected
}
^
2 errors
Output completed (2 sec consumed)
what could be the problem please help me
Thanks in advance
Raghu
- 03-01-2009, 03:41 PM #2
Check the code's brackets
It looks like your doPost() method brackets "{}" are not correct. Please check that the closing bracket is in the correct place.
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 04-21-2009, 11:12 PM #3
Member
- Join Date
- Apr 2009
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Illegal Start of Expression
By vince425 in forum New To JavaReplies: 3Last Post: 10-18-2008, 07:41 AM -
illegal start of expression
By razmyasdfg in forum CLDC and MIDPReplies: 2Last Post: 07-27-2008, 10:44 PM -
Illegal Start of an Expression
By David55 in forum CLDC and MIDPReplies: 8Last Post: 11-02-2007, 09:11 PM -
Illegal start of expression
By gabriel in forum New To JavaReplies: 2Last Post: 08-01-2007, 05:09 PM -
Illegal Start of an Expression
By David55 in forum CLDC and MIDPReplies: 0Last Post: 04-20-2007, 05:59 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks