问题
I am writing a servlet jsp under Glassfish to download a file from a website, do some processing and display the result in webpage.
When I deploy the servlet, it get this error :
java.io.IOException: Server returned HTTP response code: 503 for
URL: www.websitename.com error.
I check the status code 503 out and it turns out to be a server overload indicator.
However, if I write a standalone program, accessing the same website, it works fine.
What can be the reason of the IOException?
回答1:
I tried it using HttpClient (no other configuration needed), and everything works fine. Still I have no idea why HttpClient works, but it's definitely a way to try out if you have similar problem.
回答2:
Is Glassfish running on the same server you're running your standalone program from? If not, it's most likely a network connectivity issue on the machine Glassfish is on. Even if both Glassfish and the standalone application is running on the same machine, it's still possible that it's a network configuration issue (e.g., Glassfish isn't configured to use a proxy when you're supposed to).
来源:https://stackoverflow.com/questions/1506722/weird-java-io-ioexception-server-returned-http-response-code-503-for-url