[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

posting data using urlconnection

Posted on 2006-07-12
12
Medium Priority
?
405 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 1260 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 140 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month18 days, 19 hours left to enroll

834 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