Solved

posting data using urlconnection

Posted on 2006-07-12
12
388 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 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
String array comparison 4 46
ejb entity bean example 2 38
ejb mdb examples 1 21
jsp error 6 46
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…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

726 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