Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does HttpURLConnection work when post data to server?

 
lyj csu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to test HttpServletRequest.getParameter(), and post data with OutputStream from HttpURLConnection, my data is like this:



I get data in my servlet class:



the result is, I can only get part of data: "hello", so I want to find what happened when in HttpURLConnection ,but I even can't find the source code of
getOutputStream
in HttpURLConnection .

When I come to HttpClient, I can't get any value of the key:



Can anyone help me ? Or just tell me how to find the source code of getOutputStream in HttpURLConnection? Thank you.
 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lyj csu wrote:
the result is, I can only get part of data: "hello", so I want to find what happened when in HttpURLConnection ,but I even can't find the source code of


That's because "key=hello" is the complete, first parameter. The ampersand signifies the start of the second parameter. I think you are looking for "key=hello%20world".

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value needs to be URL-encoded; otherwise, as J. pointed out, the & character is interpreted as a delimiter.

See URLEncoder
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic