This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt Midlet-ProxyServlet

 
Carlos G�mez
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers !

I have a http communication between a midlet and servlet proxy.

1. I send a string from midlet to servlet with dos.writeUTF("I'm midlet") and the proxy receives the string with dis.readUTF()
2. then i write a string from servlet to midlet in the same way ...
3. from here all that's right !

the problem here is when i try to send another string from midlet to servlet, i don't know

the midlet throws the next exception:
"Uncaught exception java/lang/IllegalStateException: Write attempted after request finished."
anyone know why ?

In some projects i sent all messages in a DataOutputStream and then
i received all responses in a DataInputStream ...

but in this case a want to send, receive, send, receive ... and so on
anyone can help me ?


Thanks in advance
[ June 29, 2007: Message edited by: Carlos G�mez ]
 
Oscar Kamau
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gomez,
I hope am answering your question.
There is a class called the HttpConnectionHelper. You will find it here. It has the Callback interface that defines the prepareRequest method. The class used implements this interface defines this method and having this line of code, which I suspect will solve your problem. httpConnection.setRequestProperty("Content-Length",Integer.toString(data.length));
You may study this code from sun. Hope it will be helpful. Regards.
 
Oscar Kamau
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gomez - forgot something,
I hope am answering your question.
There is a class called the HttpConnectionHelper. You will find it here. It has the Callback interface that defines the prepareRequest method. The class used implements this interface defines this method and having this line of code, which I suspect will solve your problem.
refers to the byte[] that the MIDlet is transmiting to the server.
You may study this code from sun. Hope it will be helpful. Regards.
 
Carlos G�mez
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you oscar,

but my question is how can i send/receive, send/receive, send/receive data in a midlet without the midlet throws an exception, or why throws the exception showed above ?

If you try send/receive, at least 2 times you will see the same exception.
For example:
1- I send my login and then I receive the confirmation
2- I send another data and then I receive another data.
3- throw the exception.
 
Oscar Kamau
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Carlos,
The exception is probably being thrown because you have not closed a connection. This is my guess:
Instead have this:Hope it helps.
Regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic