Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-04-2008, 08:03 AM
Member
 
Join Date: Apr 2008
Posts: 1
girija is on a distinguished road
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();
}
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-04-2008, 08:07 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
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!
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-04-2008, 08:13 AM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
can u give complete code....
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +3. The time now is 04:47 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org