When I run the j2me user interface for this code, it shows me the println() given in the code, but email is not sent to the specific account.
Kindly check this code and tell me if something is wrong.\
You can't run a servlet inside of Java ME because the classes, like java.net.*, don't exist in Java ME. The only resources you can find here, in this section of forum, is the types of connections that Java ME can make. But you also need a pop/smtp email server to connect to that actually sends the message and for that you need some advice from people who know java server or other types of servers.
Java ME just has the following packages:
Plus whatever networking packages ship in MSA (jsr 248)...
JSR 82 Bluetooth,
205 Wireless Messaging,
172 Web Services,
-- maybe one of them has a network connection you can use??
Plus the brand-specific custom API extensions that cell phone makers (such a Nokia) include in their phones.
I got the code from the following site: http://developers.sun.com/mobility/midp/articles/socketRMI/
I have seen people ask about server-side scripting before, but I don't know enough about the server side of things to actually point people at the solution. Supposedly you wouldn't even need a servlet just something, anything, just so long as it can answer a connection call then act on it which means you might have better luck on one of the dedicated forms for one of the Server-side languages. (Some server-side scripts are more supported than others, PHP is a popular one for example.)
As Wikipedia says:
Some server-side scripting languages:
ASP (*.asp, *.aspx)
C via CGI (*.c, *.csp)
ColdFusion Markup Language (*.cfm)
Java via JavaServer Pages (*.jsp)
Lua (*.lp *.op)
Perl CGI (*.cgi, *.ipl, *.pl)
Python via Django (*.py)
Ruby, e.g. Ruby on Rails (*.rb, *.rbw)
Progress WebSpeed (*.r,*.w)