Forums Register Login

POST parameter coming in null

+Pie Number of slices to send: Send
I'm hoping I've a small mistake I'm not seeing.

In this simple demo, the POST parameter is coming in null. In other words, it ain't being received by the Servlet.

from Midletfrom ServletAnybody see what I'm doing wrong?
+Pie Number of slices to send: Send
I could be completely wrong, as I usually am.

But you are sending the taskid as the content, not as a parameter.

Usually what I do is add it to the URL string as in

www.website.com/servlet?taskId=1

and pass that string to the Connector.open method.

Something along those lines and that would work. I don't have actual sample code anymore to show if I remembered correctly or not.

Mark
+Pie Number of slices to send: Send
I think you answered yourself correct.
+Pie Number of slices to send: Send
Mark, I believe you were correct.

From the documentation of HttpConnection, I thought I understood that the request parameters had to be sent before an output stream was established, but I couldn't figure out another mechanism for sending request parameters. I'd not realized that POST request parameters could be sent as part of the URL, as GET request parameters are sent. (I was following an example from a book for making a POST request, which also didn't work for me. Who knew you can't believe everything you read?)

Thanks for the lesson.
+Pie Number of slices to send: Send
 

Originally posted by Dirk Schreckmann:
(I was following an example from a book for making a POST request, which also didn't work for me. Who knew you can't believe everything you read?)



Hope this is not my book that you were talking about!
+Pie Number of slices to send: Send
It wasn't.
+Pie Number of slices to send: Send
Your code is perfectly valid. The missing POST parameter is due to a known issue (a perf optimization infact!) where in the Transfer-encoding:chunked HTTP header gets set automatically when you do an out.flush(). You basically loose the POST data if the webserver is unable to recognise a chunked request properly.

So just comment out the out.flush() from your code and see the magic!
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1364 times.
Similar Threads
javax.microedition.io.ConnectionNotFoundException: TCP open
server error 500
error 500
Servlet post to server using HttpUrlConnection
Problem with using HttpsURLConnection
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:08:12.