Results 1 to 3 of 3
Thread: HttpConnection problem
- 04-04-2008, 07:03 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 1
- Rep Power
- 0
HttpConnection problem
In my code I am sending the request to server and response also i am receiving
after this one outputstream is not working one exception is came that is
java.lang.IllegalStateException: Write attempted after request finished
at com.sun.midp.io.j2me.http.Protocol.writeBytes(Prot ocol.java:997)
at com.sun.midp.io.BaseOutputStream.write(ConnectionB aseAdapter.java:696)
at java.io.OutputStream.write(OutputStream.java:58)
at MobileMail.SendAndreceiveData(MobileMail.java:1211 )
at MobileMail.Connection(MobileMail.java:481)
at MobileMail.startdata(MobileMail.java:368)
at MobileMail.startApp(MobileMail.java:170)
at javax.microedition.midlet.MIDletProxy.startApp(MID letProxy.java:44)
at com.sun.midp.midlet.Scheduler.schedule(Scheduler.j ava:372)
at com.sun.midp.main.Main.runLocalClass(Main.java:461 )
at com.sun.midp.main.Main.main(Main.java:126)
I amrequrired to send ofter that one so plz help me
My code is
public void Connection() {
{
try {
socket = (HttpConnection) Connector.open("http://" +
ipAddress.getString() + ":80");
//HTTP Request
socket.setRequestMethod(HttpConnection.GET);
socket.setRequestProperty("Content-Type", "//text plain");
socket.setRequestProperty("Connection", "Keep-Alive");
out = socket.openOutputStream();
//socket.setRequestProperty("Connection", "close");
// HTTP Response
System.out.println("Status Line Code: " + socket.getResponseCode());
System.out.println("Status Line Message: " +
socket.getResponseMessage());
System.out.println("Connector After");
if (socket.getResponseCode() == HttpConnection.HTTP_OK) {
in = socket.openInputStream();
}
} catch (Exception e) {
}
}
SendAndreceiveData();
}
private void SendAndreceiveData() {
try {
int ch;
while ((ch = in.read()) != 0) {
// data_Store = in.read();
string = string + (char) ch;
System.out.println(string);
if ((char) ch == '\n')
break;
}
if (!(string.equals(""))) {
sub_Value = string.substring(value, value + 4);
System.out.println("sub_Value::" + sub_Value);
}
if (sub_Value.equals("+OK ")) {
if (!(CountOks == 5))
CountOks++;
if (CountOks == 1) {
System.out.println("Inside the +ok" + CountOks);
String user_Name = "USER girija\r\n";
out.write(user_Name.getBytes()); //Exception
//This is musu for me so any othe ideas are ther plz inform me
} catch (Exception e) {
e.printStackTrace();
}
}
- 04-04-2008, 07:07 AM #2
Welcome to the Java Forums.
Please take note that you have posted to the wrong forum and I have taken the liberty to move it to the correct forum so that your topic gets the proper attention.
Please make use of the [ code] [ /code] tags when posting- it makes it easier to read for those viewing your code.
Lastly, please read the FAQ before you post again as you've made several infractions with your first post here.
Thank you for your cooperation and understanding. Best of luck with your topic.
Take care and see you around! :)Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
- 04-04-2008, 07:13 AM #3


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks