This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

POST parameter coming in null  RSS feed

 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
ranger
Posts: 17344
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you answered yourself correct.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
author
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It wasn't.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Beauty is in the eye of the tiny ad.
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!