Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

posting data using urlconnection

Posted on 2006-07-12
12
Medium Priority
?
403 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

636 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