Solved

posting data using urlconnection

Posted on 2006-07-12
12
367 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Which is the latest version of Apache Tomcatl 3 50
DO we need Java installed on a Windows PC and WHY ? 13 97
Java passing arguments (type error) 2 48
eclipse formatting 6 72
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now