Hi Java Rancher's,
I am trying to implement SMS application in Java. I am facing an error. No idea How to fix it.
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 400 for URL: http://www.way2sms.com/FirstServletsms?custid= at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245)
Java Result: 1
Appreciate your response on it in advance!!
SCJP 82%, SCWCD 94%, Thinking about SCEA
The server is returning status code 400, which means it didn't understand your request -- i.e., the data you sent to the server was ill-formed. We can't tell you how to fix it, since you're not showing us any code.
The stack trace doesn't tell us anything -- the original error message has all the information you need. The URL you're trying to use is not valid; the server doesn't like the inputs you're sending to it. I don't know anything about this servlet or what it expects. You need to learn about it so you can send the correct parameters. I don't think we can help you any more here; you're going to have to go do a little research on the proper way to post to that servlet. In other words, it's not a Java programming problem.
Anjali GauravSingh wrote:Well, I am still trying to debug the application. Could not find the solution. URL is valid when i execute it from browser. Any advice is appreciable
I had same issue as your's and ONLY work-around I found was to use apache commons http-client. Usng HttpURLConnection, I can not connect several web servers, and I use http-client from commons in that case. Still exploring the root cause of failure.
I experienced the same error while writing a similar sms class. After much running around and searching, i eventually found it was the proxy server at my office that was refusing connections.
I suggest you also look at this possibility in your own case.
oops! old thread... I didn't look at the dates. Hope my contribution still helps someone though!