This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does HttpURLConnection work when post data to server?

 
lyj csu
Greenhorn
Posts: 1
  • 0
  • 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: 1606
15
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • 0
  • 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: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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