posting xml to a URL

To post data to a URL, let's say (http://999.99.99.99:9999), does the url need to be concatenated with any addtional syntax or it is as simple as
opening the connection,  setting doOutput to true, and then creating an outputStream
and then writing to it?

Do I need to flush the outputStream too?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You need to have some active enitity behind that URL which would read your data - it should be servlet or PHP script or CGI, or something which should be a process ready to accept your data

Then you indeed acn setDoOutput(true), etc. like in this example:
It usually is more than just address and port because the URL mentions that active entity which accepts your data. I don't think it is an absolute law, I guess you can invenet something to make this script accept your data by deafult on certain address and port, but as a rule after address and port you mention the name of that script which accepts your data, name of servlet or PHP ascript or something like that
dpalyca755Author Commented:
If I create a URLConnection and open it, but do not open an outputStream on it yet, will I see activity on the server side socket or is it not until the stream is opened?
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

I am not sure how you mean to see activity on the server side socket until the stream is opened.
dpalyca755Author Commented:
If I am polling the socket on the URL's code will something be sent when the line
URLConnection con = url.openConnection(); is invoked, or is nothing sent until
con.getOutputStream() line in executed?
No it does not start communicating until you get stream; read the accepted solution here:
dpalyca755Author Commented: if the connection is refused upon opening the outputStream, a response or exception will be raised as long as the conn.getOutputStream() is in a try block,
or do I also need to open an inputStream to receive the potential reject?
dpalyca755Author Commented:
Also: for inputStreams I would expect to see the server side socket get hit once with a GET query, whereas should I expect the outputStream to hit the socket twice, ie.. once with a POST and no data, and the the data from the actual write()?
>or do I also need to open an inputStream to receive the potential reject?

I don't think there could be an universal answer to that question.
If you get no response say because you have incorrect address, then it makes no sense to open input stream. If you are rejected by the script in your URL which analyzed the data and prepared some srror message - then maybe inputStream will be necessary

i think it is better to deal with this situation using very concrete example - what kind of URL you are contacting and what you want to achieve. There are many variants of different types and situations of failures and we'll not predict all cases theoretically
dpalyca755Author Commented:
I will need to ask the url developer I am working with this question.
When you say "what type of URL"?  What are you asking for exactly?
dpalyca755Author Commented:
All I know at this moment is it is a http url to which I want to post XML data to.
If I were you I'd try to use the code along the line of this example:
and then see what is happening.
If you see the problems then ask the URL developer if it is someone you could contact

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.