Solved

posting data using urlconnection

Posted on 2006-07-12
12
376 Views
Last Modified: 2008-02-26
How can I post data to a url using the urlconnection class.the data to be posted is a string.
I also need to set the content type, can you show what I need to set as the content type

thanks in advance
0
Comment
Question by:inzaghi
  • 8
  • 3
12 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 315 total points
ID: 17089680
0
 

Author Comment

by:inzaghi
ID: 17089689
dont I need to set the content type?
0
 
LVL 35

Expert Comment

by:girionis
ID: 17089690
As for the content type I already answered to you here: http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21901926.html (my very first comment)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 35

Expert Comment

by:girionis
ID: 17089705
inzaghi,
> dont I need to set the content type?

YOu will need to use the following: urlConn.setRequestProperty("Content-Type", "<your content type here>");
0
 

Author Comment

by:inzaghi
ID: 17089711
what content type is set for strings
0
 
LVL 35

Expert Comment

by:girionis
ID: 17089718
YOU do not need to set any content type for strings.
0
 
LVL 35

Expert Comment

by:girionis
ID: 17089723
Maybe you can try plain/text. Are you sending form parameters?
0
 
LVL 35

Expert Comment

by:girionis
ID: 17089727
> plain/text

text/plain I mean
0
 

Author Comment

by:inzaghi
ID: 17089736
Is it correct, u only set the content type for post operations and not for get?
0
 
LVL 35

Expert Comment

by:girionis
ID: 17089782
Hmm... Not sure but I guess yes, since with GET you cannot send binary data or XML for instance, just strings.
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 35 total points
ID: 17089862
You don't need to set it for GET (I don't remember doing it but still got the output).
0
 
LVL 35

Expert Comment

by:girionis
ID: 17090280
:)
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to parse custom JSON to POJO java 4 73
java 8 lambda expresssions exception handling 3 90
rhino JavaScript import, load 25 82
even odd program using while loop 3 40
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question