Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

doubt Midlet-ProxyServlet  RSS feed

 
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 ]
 
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
Boost this thread!