0

I am using java to connect to a website which has a form of type "multipart/form-data". It asks a user, pass, and file to upload.

When i run my java project, the response i get is "200". According to w3.org, anything in the 2xx class of HTTP responses indicates that "the client's request was successfully received, understood, and accepted."

My question is, if this is the response code i get, can i assume that the file was DEFINITELY uploaded to the site, and that there was no error? To put it in other wording, is the code "200" a guarantee that the file i sent is on the server, or is it just indicating that my POST request was understood?

Thank you!

3
  • It really depends on your Java HTTP server/services implementation. We don't know what it is doing after it receives the file. Perhaps it is deleting the file. Perhaps it is pushing the file to the file system, but it is then getting eaten by anti-virus. etc. Commented Jan 27, 2014 at 15:26
  • no. I am connecting to the website in order to automatically upload a file. My java program is the client, not the server. Commented Jan 27, 2014 at 15:26
  • I see what you are saying. The wording is weird, but probably acceptable. I'd probably call that an HTTP or Web application rather than a website. Commented Jan 27, 2014 at 15:28

1 Answer 1

2

The HTTP status code 200 states that

The request has succeeded.

The server is therefore telling you that the request you made was successful. However, this doesn't tell you anything about what the web application did. It's up to the web application itself to tell you, possibly as part of the HTTP response.

You should check the web application API or specification and interpret the HTTP response accordingly.

Sign up to request clarification or add additional context in comments.

8 Comments

Would any useful info be given, besides "200 OK." if i did this: ((HttpURLConnection) connection).getResponseMessage() ? The documentation for this method in my IDE is ambiguous about this. In other words, how would i get the full response, or maybe even the code for the page that i would see if i was manually filling out the form? The site DOES kick out error codes for things like wrong user/pass or wrong file type.
@Drifter64 Again, it depends on the implementation. You haven't provided us any information about the HTTP server side.
@Drifter64 No, that method just gives the reason phrase. So for 200 OK, it would give you OK.
@Drifter64 Status codes are HTTP server/client specific. Your web application does application specific things.
@crush, i did update my comment moments before you commented. The server side is somewhat unknown to me as it belongs to someone else. What i know is what ive just given, which is that the page will direct me to another URL with error codes if i manually upload from a browser. I'm wanting to get this page data somehow with my URLConnection/HttpURLConnection object.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.