|
hi for all
(SORRY FOR MY BAD ENGLISH)
i am really thank you all because you always help me
today i am working in sending something from mobile using J2ME to localhost
i put the defalutUrl="http://localhost" is this right?
and how to the bytes (that i sent) to localhost ,
i read that the class "HttpServlet" and its functions is important to me is this right?
the most important thing is how to receive to localhost and should i make a php page to receive the bytes i sent?
this is the code
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
public class midle extends MIDlet implements CommandListener {
private static String defalutUrl="http://localhost";
private Display myDisplay=null;
private Form mainScreen;
private TextField requestField;
private Form resultScreen;
private StringItem resultField;
Command sendCommand = new Command("SEND", Command.OK, 1);
Command backCommand = new Command("BACK", Command.OK, 1);
public midle() {
myDisplay=Display.getDisplay(this);
mainScreen=new Form("Type in a string:");
requestField=new TextField(null, "TOTTI ", 100, TextField.ANY);
mainScreen.append(requestField);
mainScreen.addCommand(sendCommand);
mainScreen.setCommandListener(this);
}
public void commandAction(Command c, Displayable d) {
if(c==sendCommand){
String requestString= requestField.getString();
String resultString= sendPostRequest(requestString);
resultScreen=new Form("result String");
resultField=new StringItem(null,resultString);
resultScreen.append(resultField);
resultScreen.addCommand(backCommand);
resultScreen.setCommandListener(this);
myDisplay.setCurrent(resultScreen);
}else{
if(c==backCommand){
requestField.setString("SOMETHING GOOD");
myDisplay.setCurrent(mainScreen);
}else{
}
}
}
public String sendPostRequest(String requestString){
HttpConnection hc=null;
DataInputStream dis=null;
DataOutputStream dos=null;
StringBuffer messagebuffer=new StringBuffer();
try {
hc=(HttpConnection)Connector.open(defalutUrl,Connector.READ_WRITE);
hc.setRequestMethod(HttpConnection.POST);
dos=hc.openDataOutputStream();
byte[] requst_budy=requestString.getBytes();
for(int i=0;i<requst_budy.length;i++){
dos.writeByte(requst_budy[i]);
}
dos.flush();
dos.close();
dis=new DataInputStream(hc.openInputStream());
int ch;
long len=hc.getLength();
if(len!=-1){
for(int i=0;i<len;i++)
if((ch=dis.read())!=-1){
messagebuffer.append((char)ch);
}else{
while((ch=dis.read())!=-1){
messagebuffer.append((char)ch);
}
}
}
dis.close();
} catch (IOException ioe) {
messagebuffer.append("ERROR!");
}finally{
try {
if(hc!=null)
hc.close();
} catch (Exception e) {
}
try {
if(dis!=null)
dis.close();
} catch (Exception e) {
}
try {
if(dos!=null)
dos.close();
} catch (Exception e) {
}
return messagebuffer.toString();
}
}
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
myDisplay.setCurrent(mainScreen);
}
}
thank you very much
|
|
|
|
|
it is not working. i am getting below error. Kindly provide code in zip for both sending and receiving SMS in java Midlet.
Thanks in advance
|
|
|
|
|
hi for all
(SORRY FOR MY BAD ENGLISH)
i am studing J2EE when i being studing in the tutorial i fount this
1. Choose FileNew Project. In the Categories tree, choose Web. Under
Projects, choose Web Application. Click Next.
2. In the Project Name field, type helloservice. In the Project Location
field, browse to the location where all your projects are stored. In the
Server field, make sure that the Sun Java System Application Server Platform
Edition is selected. (If the Sun Java System Application Server is not
available in the Server field, you need to register it in the IDE. Choose
ToolsServer Manager to do so.) Click Finish.
i use NetBeans IDE 6.7
in the step two , i don't fount the selected area Sun Java System Application
and i don't found tools Server
what sould i do
have i to install another Netbeans?
thank you all
|
|
|
|
|
You don't have to re-install Netbeans to fix the issue. You may have forgotten to install the Web Server with the original installation. So you will have to add one manually using the Tools -> Server Manager.
If you can't find an web server on your computer and you don't know how to install one manually, rerunning the netbeans installer will provide you the option to install one. Please note that you should have installed the Netbeans IDE for Java (Netbeans 6.9.1 Java Edition[^])
|
|
|
|
|
really thank you
i see that Glassfish is good
thank you too much
|
|
|
|
|
Does it say Glassfish in the list of options? If it does, you can use this. It sounds as if your tutorial is a little out of date.
|
|
|
|
|
you are amazing
really thank you
tooooooooooooooooooooooooo much
|
|
|
|
|
hello,
plz send me the full code in J2ME for "sending sms from mobile to gmail inbox"...
its urgent...thank u..
|
|
|
|
|
No, it's still not urgent.
[edit]I notice you only joined CodeProject today, so perhaps you did not take the time to read this[^]; probably due to all this urgency.[/edit]
|
|
|
|
|
I like your answer............ People need to read before posting or asking questions......
|
|
|
|
|
I am not sure about it but this link[^] might help you.
|
|
|
|
|
i need code in java(J2EE) for implementation of firewall...itz urgent...
plz send me the full code...thank u..
|
|
|
|
|
It's not urgent. If you need code then you need to write it yourself or pay for it.
|
|
|
|
|
It's also SO urgent - plz send me the full money!
regards
Torsten
PS: No, I don't have the code, but I would take the money anyway!
I never finish anyth...
|
|
|
|
|
Before asking for the whole code, why don't you first try it yourself and then if you have difficulties, people here will be happy to help. But asking for codes directly is not good. No one here is working for you we are just wanting to help those who help themselves..........
|
|
|
|
|
that's the best thing........... no noe should ask the whole codes here........
|
|
|
|
|
First, Do google, Try yourself something, do some RnD, then come here with doubts and ask it.
***** Programme comme si dept soutien technique. est plein de tueurs en série et ils savent adresse de votre domicile. *****
|
|
|
|
|
I need a few very large ( >= 500K loc ) opensource Java and C# source code repositories to test some ideas. Do you know any?
Thanks,
|
|
|
|
|
isn't SourceForge[^] the one to go with? I actually don't even know others
Does it need to be a repository? Otherwise you could go with a service like dropbox or so.
regards
Torsten
I never finish anyth...
|
|
|
|
|
I mean single large project
|
|
|
|
|
There are lots of projects in sourceforge and also in Codeplex[^]; go and have a look.
|
|
|
|
|
Hi Richard,
I know. I just wanted to get specific project names. I got them. Thanks.
|
|
|
|
|
|
hi for all
(SORRY FOR MY BAD ENGLISH)
please i want this jar file
javax,microedition
free
thank you all
|
|
|
|
|
is Google down again? one can't depend on faulty services like that!
call it Java ME[^]
regards,
Torsten
I never finish anyth...
|
|
|
|