Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 407
  • Last Modified:

posting data using urlconnection

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
inzaghi
Asked:
inzaghi
  • 8
  • 3
2 Solutions
 
inzaghiAuthor Commented:
dont I need to set the content type?
0
 
girionisCommented:
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
girionisCommented:
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
 
inzaghiAuthor Commented:
what content type is set for strings
0
 
girionisCommented:
YOU do not need to set any content type for strings.
0
 
girionisCommented:
Maybe you can try plain/text. Are you sending form parameters?
0
 
girionisCommented:
> plain/text

text/plain I mean
0
 
inzaghiAuthor Commented:
Is it correct, u only set the content type for post operations and not for get?
0
 
girionisCommented:
Hmm... Not sure but I guess yes, since with GET you cannot send binary data or XML for instance, just strings.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
You don't need to set it for GET (I don't remember doing it but still got the output).
0
 
girionisCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now